changed sponsor logo to be filename only (#280)

* changed sponsor logo to be filename only

fixes issue #151

* changed to load logo correctly on sponsor tickets

related to fix of issue #151
This commit is contained in:
Thomas Flummer 2018-11-20 00:20:37 +01:00 committed by Thomas Steen Rasmussen
parent 95cd376f36
commit 9b2640ea07
6 changed files with 63 additions and 4 deletions

View file

@ -0,0 +1,18 @@
# Generated by Django 2.1.2 on 2018-11-18 13:40
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('sponsors', '0008_auto_20180815_1119'),
]
operations = [
migrations.AddField(
model_name='sponsor',
name='logo_filename',
field=models.CharField(blank=True, help_text='Filename of the logo', max_length=255, null=True),
),
]

View file

@ -0,0 +1,19 @@
# Generated by Django 2.1.2 on 2018-11-18 13:42
from django.db import migrations
def populate_logo_filename(apps, schema_editor):
Sponsor = apps.get_model('sponsors', 'Sponsor')
for sponsor in Sponsor.objects.all():
sponsor.logo_filename = sponsor.logo.split("/")[-1]
sponsor.save()
class Migration(migrations.Migration):
dependencies = [
('sponsors', '0009_sponsor_logo_filename'),
]
operations = [
migrations.RunPython(populate_logo_filename),
]

View file

@ -0,0 +1,22 @@
# Generated by Django 2.1.2 on 2018-11-18 14:13
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('sponsors', '0010_populate_logo_filename'),
]
operations = [
migrations.RemoveField(
model_name='sponsor',
name='logo',
),
migrations.AlterField(
model_name='sponsor',
name='logo_filename',
field=models.CharField(help_text='Filename of the logo', max_length=255),
),
]

View file

@ -25,9 +25,9 @@ class Sponsor(CampRelatedModel):
help_text='A short description of the sponsorship'
)
logo = models.URLField(
logo_filename = models.CharField(
max_length=255,
help_text='A URL to the logo'
help_text='Filename of the logo'
)
url = models.URLField(

View file

@ -39,7 +39,7 @@ Sponsors | {{ block.super }}
{% if sponsor.url %}
<a href="{{ sponsor.url }}">
{% endif %}
<img class="img-responsive center-block" src="{{ sponsor.logo }}" width="300" />
<img class="img-responsive center-block" src="{% static 'img/sponsors/' %}{{ sponsor.logo_filename }}" width="300" />
{% if sponsor.url %}
</a>
{% endif %}

View file

@ -23,7 +23,7 @@
<br>
{% elif ticket.sponsor %}
<h3>Sponsor: {{ ticket.sponsor.name }} </h3>
<img src="{{ ticket.sponsor.logo }}"></img>
<img src="{% static 'img/sponsors/' %}{{ sponsor.logo_filename }}"></img>
{% endif %}
{% if ticket.checked_in %}
<h2>This ticket has been checked in.</h2>