From: Radek Czajka Date: Thu, 10 Jun 2021 12:46:53 +0000 (+0200) Subject: Banner colors. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/c8d364d4d3331d03a079d200887e5462279fd875?ds=sidebyside;hp=26b58a58e22d92250ae9dcf79d3b86aca173190a Banner colors. --- diff --git a/src/annoy/admin.py b/src/annoy/admin.py index 24e977e2b..8255e96a5 100644 --- a/src/annoy/admin.py +++ b/src/annoy/admin.py @@ -5,7 +5,11 @@ from . import models class BannerAdmin(TranslationAdmin): - list_display = ['place', 'text', 'priority', 'since', 'until', 'show_members', 'staff_preview'] + list_display = [ + 'place', 'text', + 'text_color', 'background_color', + 'priority', 'since', 'until', + 'show_members', 'staff_preview'] admin.site.register(models.Banner, BannerAdmin) diff --git a/src/annoy/migrations/0011_auto_20210610_1437.py b/src/annoy/migrations/0011_auto_20210610_1437.py new file mode 100644 index 000000000..f51d3d87b --- /dev/null +++ b/src/annoy/migrations/0011_auto_20210610_1437.py @@ -0,0 +1,23 @@ +# Generated by Django 2.2.19 on 2021-06-10 12:37 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('annoy', '0010_auto_20210430_1331'), + ] + + operations = [ + migrations.AddField( + model_name='banner', + name='background_color', + field=models.CharField(blank=True, max_length=10), + ), + migrations.AddField( + model_name='banner', + name='text_color', + field=models.CharField(blank=True, max_length=10), + ), + ] diff --git a/src/annoy/models.py b/src/annoy/models.py index fe5f8fafb..55bb2ac38 100644 --- a/src/annoy/models.py +++ b/src/annoy/models.py @@ -15,6 +15,8 @@ class Banner(models.Model): help_text=_('Affects blackout.') ) smallfont = models.BooleanField(_('small font'), default=False) + text_color = models.CharField(max_length=10, blank=True) + background_color = models.CharField(max_length=10, blank=True) action_label = models.CharField( _('action label'), max_length=255, blank=True, diff --git a/src/annoy/templates/annoy/banner.html b/src/annoy/templates/annoy/banner.html index 97f10c1ad..4b2bdcfb8 100644 --- a/src/annoy/templates/annoy/banner.html +++ b/src/annoy/templates/annoy/banner.html @@ -13,7 +13,12 @@ annoy-banner-style_{{ banner.style }} {% if banner.image %}with-image{% endif %} {% if banner.smallfont %}banner-smallfont{% endif %} - " id="annoy-banner-{{ banner.id }}"> + " + id="annoy-banner-{{ banner.id }}" + style=" + {% if banner.text_color %}color: {{ banner.text_color }};{% endif %} + {% if banner.background_color %}background-color: {{ banner.background_color }};{% endif %} + "> {% if not banner.action_label %} {% endif %}