forked from mozilla/addons-server
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-implement cinder forwards (escalations) as a property of the job
- Loading branch information
Showing
11 changed files
with
392 additions
and
363 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
33 changes: 33 additions & 0 deletions
33
src/olympia/abuse/migrations/0037_cinderjob_is_forwarded_cinderjob_notes_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,33 @@ | ||
# Generated by Django 4.2.15 on 2024-08-19 12:58 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('abuse', '0036_alter_abusereport_appellant_job_cinderappealtext'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='cinderjob', | ||
name='is_forwarded', | ||
field=models.BooleanField(default=False), | ||
), | ||
migrations.AddField( | ||
model_name='cinderjob', | ||
name='notes', | ||
field=models.CharField(max_length=255, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='cinderdecision', | ||
name='action', | ||
field=models.PositiveSmallIntegerField(choices=[(1, 'User ban'), (2, 'Add-on disable'), (3, 'Escalate add-on to reviewers'), (5, 'Rating delete'), (6, 'Collection delete'), (7, 'Approved (no action)'), (8, 'Add-on version reject'), (9, 'Add-on version delayed reject warning'), (10, 'Approved (new version approval)'), (11, 'Invalid report, so ignored'), (12, 'Content already removed (no action)')]), | ||
), | ||
migrations.AlterField( | ||
model_name='cinderpolicy', | ||
name='default_cinder_action', | ||
field=models.PositiveSmallIntegerField(blank=True, choices=[(1, 'User ban'), (2, 'Add-on disable'), (3, 'Escalate add-on to reviewers'), (5, 'Rating delete'), (6, 'Collection delete'), (7, 'Approved (no action)'), (8, 'Add-on version reject'), (9, 'Add-on version delayed reject warning'), (10, 'Approved (new version approval)'), (11, 'Invalid report, so ignored'), (12, 'Content already removed (no action)')], null=True), | ||
), | ||
] |
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,46 @@ | ||
# Generated by Django 4.2.15 on 2024-08-19 13:43 | ||
|
||
from django.db import migrations, models | ||
|
||
from olympia.constants.abuse import DECISION_ACTIONS | ||
|
||
|
||
def migrate_escalate_action_to_is_forwarded(apps, schema_editor): | ||
CinderDecision = apps.get_model('abuse', 'CinderDecision') | ||
CinderJob = apps.get_model('abuse', 'CinderJob') | ||
|
||
CinderJob.objects.filter( | ||
decision__action=DECISION_ACTIONS.AMO_ESCALATE_ADDON | ||
).update( | ||
is_forwarded=True, | ||
notes=models.Subquery( | ||
CinderDecision.objects.filter(pk=models.OuterRef('decision')).values('notes')[:1] | ||
) | ||
) | ||
CinderDecision.objects.filter(action=DECISION_ACTIONS.AMO_ESCALATE_ADDON).delete() | ||
|
||
|
||
def recreate_escalate_decisions(apps, schema_editor): | ||
CinderDecision = apps.get_model('abuse', 'CinderDecision') | ||
CinderJob = apps.get_model('abuse', 'CinderJob') | ||
|
||
CinderDecision.objects.bulk_create( | ||
CinderDecision( | ||
cinder_job=job, | ||
action=DECISION_ACTIONS.AMO_ESCALATE_ADDON, | ||
notes=job.notes, | ||
addon=job.target_addon | ||
) | ||
for job in CinderJob.objects.filter(is_forwarded=True) | ||
) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('abuse', '0037_cinderjob_is_forwarded_cinderjob_notes_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(migrate_escalate_action_to_is_forwarded, recreate_escalate_decisions) | ||
] |
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.