35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
|
|
# Adds Line.admin_solicited (BooleanField) to discriminate
|
||
|
|
# system-authored Lines (Note.grant_if_new) from user writes on
|
||
|
|
# NOTE_UNLOCK Posts. The post_save signal nukes any Line on a
|
||
|
|
# NOTE_UNLOCK Post that lacks admin_solicited=True — defense-in-depth
|
||
|
|
# alongside the view_post POST guard. Backfill: existing NOTE_UNLOCK
|
||
|
|
# Lines (the only system-authored kind at this point) get True; all
|
||
|
|
# others default False.
|
||
|
|
|
||
|
|
from django.db import migrations, models
|
||
|
|
|
||
|
|
|
||
|
|
def backfill(apps, schema_editor):
|
||
|
|
Line = apps.get_model("billboard", "Line")
|
||
|
|
Line.objects.filter(post__kind="note_unlock").update(admin_solicited=True)
|
||
|
|
|
||
|
|
|
||
|
|
def reverse_noop(apps, schema_editor):
|
||
|
|
pass
|
||
|
|
|
||
|
|
|
||
|
|
class Migration(migrations.Migration):
|
||
|
|
|
||
|
|
dependencies = [
|
||
|
|
("billboard", "0004_post_title_line_author_created_at"),
|
||
|
|
]
|
||
|
|
|
||
|
|
operations = [
|
||
|
|
migrations.AddField(
|
||
|
|
model_name="line",
|
||
|
|
name="admin_solicited",
|
||
|
|
field=models.BooleanField(default=False),
|
||
|
|
),
|
||
|
|
migrations.RunPython(backfill, reverse_noop),
|
||
|
|
]
|