set upload path for speaker pictures
This commit is contained in:
parent
c6b27de400
commit
cb5c2386eb
26
src/program/migrations/0023_auto_20170218_1243.py
Normal file
26
src/program/migrations/0023_auto_20170218_1243.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.5 on 2017-02-18 11:43
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import program.models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('program', '0022_auto_20170218_1148'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='speaker',
|
||||
name='picture_large',
|
||||
field=models.ImageField(blank=True, null=True, upload_to=program.models.get_speaker_picture_upload_path),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='speaker',
|
||||
name='picture_small',
|
||||
field=models.ImageField(blank=True, null=True, upload_to=program.models.get_speaker_picture_upload_path),
|
||||
),
|
||||
]
|
|
@ -102,12 +102,17 @@ class EventInstance(CreatedUpdatedModel):
|
|||
return minutes / settings.SCHEDULE_TIMESLOT_LENGTH_MINUTES
|
||||
|
||||
|
||||
def get_speaker_picture_upload_path(instance, filename):
|
||||
""" We want speaker pictures are saved as MEDIA_ROOT/speakers/bornhack-2016/filename """
|
||||
return 'speakers/%s/%s' % (instance.camp.slug, filename)
|
||||
|
||||
|
||||
class Speaker(CreatedUpdatedModel):
|
||||
""" A Person anchoring an event. """
|
||||
name = models.CharField(max_length=150)
|
||||
biography = models.TextField()
|
||||
picture_small = models.ImageField(null=True, blank=True)
|
||||
picture_large = models.ImageField(null=True, blank=True)
|
||||
picture_small = models.ImageField(null=True, blank=True, upload_to=get_speaker_picture_upload_path)
|
||||
picture_large = models.ImageField(null=True, blank=True, upload_to=get_speaker_picture_upload_path)
|
||||
slug = models.SlugField(blank=True, max_length=255)
|
||||
camp = models.ForeignKey('camps.Camp', null=True, related_name="speakers")
|
||||
events = models.ManyToManyField(
|
||||
|
@ -127,3 +132,4 @@ class Speaker(CreatedUpdatedModel):
|
|||
self.slug = slugify(self.name)
|
||||
super(Speaker, self).save(**kwargs)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue