-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This only affects the community site.
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
readthedocs/builds/migrations/0025_migrate_private_versions.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Generated by Django 2.2.12 on 2020-06-11 01:14 | ||
|
||
from django.db import migrations | ||
from django.conf import settings | ||
|
||
|
||
def forwards_func(apps, schema_editor): | ||
""" | ||
Migrate all private versions to public and hidden. | ||
.. note:: | ||
This migration is skipped for the corporate site. | ||
""" | ||
if settings.ALLOW_PRIVATE_REPOS: | ||
return | ||
|
||
Version = apps.get_model('builds', 'Version') | ||
( | ||
Version.objects | ||
.filter(privacy_level='private') | ||
.update(privacy_level='public', hidden=True) | ||
) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('builds', '0024_status_code_choices'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(forwards_func), | ||
] |