Make sponsor logos required, but fail gracefully when there isn't one

This commit is contained in:
Michael Hall 2018-09-26 18:15:32 -04:00
parent 96cad889c6
commit d35355b535
4 changed files with 29 additions and 2 deletions

View file

@ -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'),
),
]

View file

@ -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

View file

@ -42,7 +42,11 @@
<div class="card mb-1 box-shadow">
<div class="card-banner align-items-center">
<a class="card-link" href="{{sponsor.web_url}}">
{% if sponsor.logo %}
<img class="card-img-top" src="{{sponsor.logo.url}}">
{% else %}
{{sponsor.name}}
{% endif %}
</a>
</div>
<div class="card-body">

View file

@ -277,7 +277,11 @@ textarea {
{% for sponsor in sponsor_list %}
<div class="row mb-3">
<div class="col">
<a href="{{sponsor.web_url}}" target="_blank"><img src="{{sponsor.logo.url}}" alt="{{sponsor.name}} Logo" title="{{sponsor.name}}"></a>
{% if sponsor.logo %}
<a href="{{sponsor.web_url}}" target="_blank"><img src="{{sponsor.logo.url}}" alt="{{sponsor.name}} Logo" title="{{sponsor.name}}"></a>
{% else %}
<a href="{{sponsor.web_url}}" target="_blank">{{sponsor.name}}</a>
{% endif %}
</div>
</div>
{% endfor %}