From d35355b535fbf010192c70b1631e011c99937b7a Mon Sep 17 00:00:00 2001 From: Michael Hall Date: Wed, 26 Sep 2018 18:15:32 -0400 Subject: [PATCH] Make sponsor logos required, but fail gracefully when there isn't one --- .../migrations/0046_require_sponsor_logo.py | 19 +++++++++++++++++++ events/models/profiles.py | 2 +- .../events/manage_event_sponsors.html | 4 ++++ .../get_together/events/show_event.html | 6 +++++- 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 events/migrations/0046_require_sponsor_logo.py diff --git a/events/migrations/0046_require_sponsor_logo.py b/events/migrations/0046_require_sponsor_logo.py new file mode 100644 index 0000000..17b0036 --- /dev/null +++ b/events/migrations/0046_require_sponsor_logo.py @@ -0,0 +1,19 @@ +# Generated by Django 2.0 on 2018-09-26 22:14 + +from django.db import migrations +import imagekit.models.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('events', '0045_change_field_help_text'), + ] + + operations = [ + migrations.AlterField( + model_name='sponsor', + name='logo', + field=imagekit.models.fields.ProcessedImageField(help_text='Will be scaled and cropped to max 250x200 px.', upload_to='sponsors', verbose_name='Logo'), + ), + ] diff --git a/events/models/profiles.py b/events/models/profiles.py index 4d617f1..a25ff32 100644 --- a/events/models/profiles.py +++ b/events/models/profiles.py @@ -293,7 +293,7 @@ class Sponsor(models.Model): upload_to='sponsors', processors=[ResizeToFit(250, 200)], format='PNG', - blank=True) + blank=False) def __str__(self): return self.name diff --git a/get_together/templates/get_together/events/manage_event_sponsors.html b/get_together/templates/get_together/events/manage_event_sponsors.html index 105f7be..0b410f1 100644 --- a/get_together/templates/get_together/events/manage_event_sponsors.html +++ b/get_together/templates/get_together/events/manage_event_sponsors.html @@ -42,7 +42,11 @@
diff --git a/get_together/templates/get_together/events/show_event.html b/get_together/templates/get_together/events/show_event.html index ed528e6..c0cde82 100644 --- a/get_together/templates/get_together/events/show_event.html +++ b/get_together/templates/get_together/events/show_event.html @@ -277,7 +277,11 @@ textarea { {% for sponsor in sponsor_list %}
- {{sponsor.name}} Logo + {% if sponsor.logo %} + {{sponsor.name}} Logo + {% else %} + {{sponsor.name}} + {% endif %}
{% endfor %}