From cfa91e25704d8a0c73a6648761824e734458e6be Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 11 Feb 2022 14:00:01 -0500 Subject: [PATCH] Adds color options to announcements --- .../0134_announcement_display_type.py | 29 +++++++++++++++++++ bookwyrm/models/announcement.py | 18 ++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 bookwyrm/migrations/0134_announcement_display_type.py diff --git a/bookwyrm/migrations/0134_announcement_display_type.py b/bookwyrm/migrations/0134_announcement_display_type.py new file mode 100644 index 000000000..ba8450123 --- /dev/null +++ b/bookwyrm/migrations/0134_announcement_display_type.py @@ -0,0 +1,29 @@ +# Generated by Django 3.2.11 on 2022-02-11 18:59 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookwyrm", "0133_alter_listitem_notes"), + ] + + operations = [ + migrations.AddField( + model_name="announcement", + name="display_type", + field=models.CharField( + choices=[ + ("white-ter", "None"), + ("primary-light", "Primary"), + ("success-light", "Success"), + ("link-light", "Link"), + ("warning-light", "Warning"), + ("danger-light", "Danger"), + ], + default="white-ter", + max_length=20, + ), + ), + ] diff --git a/bookwyrm/models/announcement.py b/bookwyrm/models/announcement.py index 498d50418..cbed38aee 100644 --- a/bookwyrm/models/announcement.py +++ b/bookwyrm/models/announcement.py @@ -2,10 +2,21 @@ from django.db import models from django.db.models import Q from django.utils import timezone +from django.utils.translation import gettext_lazy as _ from .base_model import BookWyrmModel +DisplayTypes = [ + ("white-ter", _("None")), + ("primary-light", _("Primary")), + ("success-light", _("Success")), + ("link-light", _("Link")), + ("warning-light", _("Warning")), + ("danger-light", _("Danger")), +] + + class Announcement(BookWyrmModel): """The admin has something to say""" @@ -16,6 +27,13 @@ class Announcement(BookWyrmModel): start_date = models.DateTimeField(blank=True, null=True) 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", + ) @classmethod def active_announcements(cls):