mirror of
https://github.com/pretix/pretix.git
synced 2026-05-04 15:04:03 +00:00
Changed the upload_to of item pictures to a static functions, as lambdas
do not work in migrations
This commit is contained in:
20
src/pretix/base/migrations/0006_auto_20150726_1420.py
Normal file
20
src/pretix/base/migrations/0006_auto_20150726_1420.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
import pretix.base.models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pretixbase', '0005_item_picture'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='item',
|
||||
name='picture',
|
||||
field=models.ImageField(upload_to=pretix.base.models.itempicture_upload_to, null=True, verbose_name='Product picture', blank=True),
|
||||
),
|
||||
]
|
||||
@@ -774,6 +774,13 @@ class Question(Versionable):
|
||||
self.event.get_cache().clear()
|
||||
|
||||
|
||||
def itempicture_upload_to(instance, filename):
|
||||
return '%s/%s/item-%s.%s' % (
|
||||
instance.event.organizer.slug, instance.event.slug, instance.identity,
|
||||
filename.split('.')[-1]
|
||||
)
|
||||
|
||||
|
||||
class Item(Versionable):
|
||||
"""
|
||||
An item is a thing which can be sold. It belongs to an event and may or may not belong to a category.
|
||||
@@ -801,8 +808,11 @@ class Item(Versionable):
|
||||
:param questions: A set of ``Question`` objects that should be applied to this item
|
||||
:param admission: ``True``, if this item allows persons to enter the event (as opposed to e.g. merchandise)
|
||||
:type admission: bool
|
||||
:param picture: A product picture to be shown next to the product description.
|
||||
:type picture: File
|
||||
|
||||
"""
|
||||
|
||||
event = VersionedForeignKey(
|
||||
Event,
|
||||
on_delete=models.PROTECT,
|
||||
@@ -878,10 +888,7 @@ class Item(Versionable):
|
||||
picture = models.ImageField(
|
||||
verbose_name=_("Product picture"),
|
||||
null=True, blank=True,
|
||||
upload_to=lambda instance, filename: '%s/%s/item-%s.%s' % (
|
||||
instance.event.organizer.slug, instance.event.slug, instance.identity,
|
||||
filename.split('.')[-1]
|
||||
)
|
||||
upload_to=itempicture_upload_to
|
||||
)
|
||||
|
||||
class Meta:
|
||||
|
||||
Reference in New Issue
Block a user