-
-
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.
File tree diff: migrate feature flag to model field (#11793)
There is no need to use a feature flag for this. We can use a model field as we are doing for all the other addons. As we are not exposing this field to the user yet, they can't enable it by themselves yet. So, we still have the control of it. This follows the pattern we have for all the other addons.
- Loading branch information
Showing
14 changed files
with
165 additions
and
128 deletions.
There are no files selected for viewing
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
37 changes: 37 additions & 0 deletions
37
readthedocs/projects/migrations/0139_addons_filetreediff_field.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,37 @@ | ||
# Generated by Django 4.2.16 on 2024-11-25 11:57 | ||
|
||
from django.db import migrations, models | ||
from django_safemigrate import Safe | ||
|
||
|
||
def forwards_func(apps, schema_editor): | ||
""" | ||
Enable FileTreeDiff on those projects with the feature flag enabled. | ||
""" | ||
Feature = apps.get_model("projects", "Feature") | ||
feature = Feature.objects.filter(feature_id="generate_manifest_for_file_tree_diff").first() | ||
if feature: | ||
for project in feature.projects.all().iterator(): | ||
project.addons.filetreediff_enabled = True | ||
project.addons.save() | ||
|
||
class Migration(migrations.Migration): | ||
safe = Safe.before_deploy | ||
|
||
dependencies = [ | ||
('projects', '0138_remove_old_fields'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='addonsconfig', | ||
name='filetreediff_enabled', | ||
field=models.BooleanField(blank=True, default=False, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='historicaladdonsconfig', | ||
name='filetreediff_enabled', | ||
field=models.BooleanField(blank=True, default=False, null=True), | ||
), | ||
migrations.RunPython(forwards_func), | ||
] |
27 changes: 27 additions & 0 deletions
27
readthedocs/projects/migrations/0140_addons_options_base_version.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,27 @@ | ||
# Generated by Django 4.2.16 on 2024-11-25 12:15 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
from django_safemigrate import Safe | ||
|
||
|
||
class Migration(migrations.Migration): | ||
safe = Safe.before_deploy | ||
|
||
dependencies = [ | ||
('builds', '0059_add_version_date_index'), | ||
('projects', '0139_addons_filetreediff_field'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='addonsconfig', | ||
name='options_base_version', | ||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='builds.version', verbose_name='Base version to compare against (eg. DocDiff, File Tree Diff)'), | ||
), | ||
migrations.AddField( | ||
model_name='historicaladdonsconfig', | ||
name='options_base_version', | ||
field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='builds.version', verbose_name='Base version to compare against (eg. DocDiff, File Tree Diff)'), | ||
), | ||
] |
29 changes: 29 additions & 0 deletions
29
readthedocs/projects/migrations/0141_create_addonsconfig.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,29 @@ | ||
# Generated by Django 4.2.16 on 2024-11-26 09:04 | ||
|
||
from django.db import migrations | ||
from django_safemigrate import Safe | ||
|
||
|
||
def forwards_func(apps, schema_editor): | ||
""" | ||
Create ``AddonsConfig`` for those projects without it. | ||
We were creating these models when the user accesses to the dashboard or the API itself. | ||
Now, we are creating them on a ``post_save`` Django Signal. | ||
""" | ||
AddonsConfig = apps.get_model("projects", "AddonsConfig") | ||
Project = apps.get_model("projects", "Project") | ||
for project in Project.objects.filter(addons__isnull=True).iterator(): | ||
AddonsConfig.objects.get_or_create(project=project) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
safe = Safe.before_deploy | ||
|
||
dependencies = [ | ||
('projects', '0140_addons_options_base_version'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(forwards_func), | ||
] |
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
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
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
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
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
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
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
Oops, something went wrong.