-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PromotedGroup model to replace legacy PromotedClass
- Create new PromotedGroup model with comprehensive fields for promotion rules - Add migration to populate PromotedGroup from existing constants - Implement test coverage to ensure data integrity and migration correctness
- Loading branch information
Showing
4 changed files
with
194 additions
and
1 deletion.
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
67 changes: 67 additions & 0 deletions
67
src/olympia/promoted/migrations/0022_promotedgroup_alter_promotedaddon_group_id_and_more.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,67 @@ | ||
# Generated by Django 4.2.18 on 2025-02-04 11:13 | ||
|
||
from django.db import migrations, models | ||
from olympia.constants.promoted import PROMOTED_GROUPS_BY_ID, ACTIVE_PROMOTED_GROUP_IDS | ||
|
||
|
||
def create_promoted_groups(apps, schema_editor): | ||
PromotedGroup = apps.get_model('promoted', 'PromotedGroup') | ||
# Import legacy promoted groups from constants | ||
|
||
# Loop over all groups (active and inactive) from PROMOTED_GROUPS_BY_ID | ||
for group in PROMOTED_GROUPS_BY_ID.values(): | ||
PromotedGroup.objects.create( | ||
id=group.id, | ||
name=group.name, | ||
api_name=group.api_name, | ||
search_ranking_bump=group.search_ranking_bump, | ||
listed_pre_review=group.listed_pre_review, | ||
unlisted_pre_review=group.unlisted_pre_review, | ||
admin_review=group.admin_review, | ||
badged=group.badged, | ||
autograph_signing_states=group.autograph_signing_states, | ||
can_primary_hero=group.can_primary_hero, | ||
immediate_approval=group.immediate_approval, | ||
flag_for_human_review=group.flag_for_human_review, | ||
can_be_compatible_with_all_fenix_versions=group.can_be_compatible_with_all_fenix_versions, | ||
high_profile=group.high_profile, | ||
high_profile_rating=group.high_profile_rating, | ||
active=(group.id in ACTIVE_PROMOTED_GROUP_IDS), | ||
) | ||
|
||
|
||
def reverse_promoted_groups(apps, schema_editor): | ||
PromotedGroup = apps.get_model('promoted', 'PromotedGroup') | ||
PromotedGroup.objects.all().delete() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('promoted', '0021_auto_20240919_0952'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='PromotedGroup', | ||
fields=[ | ||
('id', models.SmallIntegerField(help_text='Primary key identifier for the promotion group.', primary_key=True, serialize=False)), | ||
('name', models.CharField(help_text='Human-readable name for the promotion group.', max_length=255)), | ||
('api_name', models.CharField(help_text='Programmatic API name for the promotion group.', max_length=100)), | ||
('search_ranking_bump', models.FloatField(help_text='Boost value used to influence search ranking for add-ons in this group.')), | ||
('listed_pre_review', models.BooleanField(default=False, help_text='Indicates if listed versions require pre-review.')), | ||
('unlisted_pre_review', models.BooleanField(default=False, help_text='Indicates if unlisted versions require pre-review.')), | ||
('admin_review', models.BooleanField(default=False, help_text='Specifies whether the promotion requires administrative review.')), | ||
('badged', models.BooleanField(default=False, help_text='Specifies if the add-on receives a badge upon promotion.')), | ||
('autograph_signing_states', models.JSONField(blank=True, default=dict, help_text='Mapping of application shorthand to autograph signing states.')), | ||
('can_primary_hero', models.BooleanField(default=False, help_text='Determines if the add-on can be featured in a primary hero shelf.')), | ||
('immediate_approval', models.BooleanField(default=False, help_text='If true, add-ons are auto-approved upon saving.')), | ||
('flag_for_human_review', models.BooleanField(default=False, help_text='If true, add-ons are flagged for manual human review.')), | ||
('can_be_compatible_with_all_fenix_versions', models.BooleanField(default=False, help_text='Determines compatibility with all Fenix (Android) versions.')), | ||
('high_profile', models.BooleanField(default=False, help_text='Indicates if the add-on is high-profile for review purposes.')), | ||
('high_profile_rating', models.BooleanField(default=False, help_text='Indicates if developer replies are treated as high-profile.')), | ||
('active', models.BooleanField(default=False, help_text='Marks whether this promotion group is active (inactive groups are considered obsolete).')), | ||
], | ||
), | ||
migrations.RunPython(create_promoted_groups, reverse_promoted_groups), | ||
] |
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