diff --git a/bookwyrm/migrations/0144_alter_announcement_display_type.py b/bookwyrm/migrations/0144_alter_announcement_display_type.py new file mode 100644 index 00000000..246dd5b4 --- /dev/null +++ b/bookwyrm/migrations/0144_alter_announcement_display_type.py @@ -0,0 +1,39 @@ +# Generated by Django 3.2.12 on 2022-03-01 18:46 + +from django.db import migrations, models + + +def remove_white(apps, schema_editor): + """don't hardcode white announcements""" + db_alias = schema_editor.connection.alias + announcement_model = apps.get_model("bookwyrm", "Announcement") + announcement_model.objects.using(db_alias).filter(display_type="white-ter").update( + display_type=None + ) + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookwyrm", "0143_merge_0142_auto_20220227_1752_0142_user_hide_follows"), + ] + + operations = [ + migrations.AlterField( + model_name="announcement", + name="display_type", + field=models.CharField( + blank=True, + choices=[ + ("primary-light", "Primary"), + ("success-light", "Success"), + ("link-light", "Link"), + ("warning-light", "Warning"), + ("danger-light", "Danger"), + ], + max_length=20, + null=True, + ), + ), + migrations.RunPython(remove_white, reverse_code=migrations.RunPython.noop), + ] diff --git a/bookwyrm/models/announcement.py b/bookwyrm/models/announcement.py index cbed38ae..4581dbda 100644 --- a/bookwyrm/models/announcement.py +++ b/bookwyrm/models/announcement.py @@ -8,7 +8,6 @@ from .base_model import BookWyrmModel DisplayTypes = [ - ("white-ter", _("None")), ("primary-light", _("Primary")), ("success-light", _("Success")), ("link-light", _("Link")), @@ -28,11 +27,7 @@ class Announcement(BookWyrmModel): end_date = models.DateTimeField(blank=True, null=True) active = models.BooleanField(default=True) display_type = models.CharField( - max_length=20, - blank=False, - null=False, - choices=DisplayTypes, - default="white-ter", + max_length=20, choices=DisplayTypes, null=True, blank=True ) @classmethod diff --git a/bookwyrm/templates/snippets/announcement.html b/bookwyrm/templates/snippets/announcement.html index ec1555d8..d9da01c9 100644 --- a/bookwyrm/templates/snippets/announcement.html +++ b/bookwyrm/templates/snippets/announcement.html @@ -1,7 +1,7 @@ {% load humanize %}{% load i18n %}{% load utilities %} {% with announcement.id|uuid as uuid %}