mirror of
https://github.com/pretix/pretix.git
synced 2026-08-27 13:24:41 +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:
@@ -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()
|
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):
|
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.
|
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 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)
|
:param admission: ``True``, if this item allows persons to enter the event (as opposed to e.g. merchandise)
|
||||||
:type admission: bool
|
:type admission: bool
|
||||||
|
:param picture: A product picture to be shown next to the product description.
|
||||||
|
:type picture: File
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
event = VersionedForeignKey(
|
event = VersionedForeignKey(
|
||||||
Event,
|
Event,
|
||||||
on_delete=models.PROTECT,
|
on_delete=models.PROTECT,
|
||||||
@@ -878,10 +888,7 @@ class Item(Versionable):
|
|||||||
picture = models.ImageField(
|
picture = models.ImageField(
|
||||||
verbose_name=_("Product picture"),
|
verbose_name=_("Product picture"),
|
||||||
null=True, blank=True,
|
null=True, blank=True,
|
||||||
upload_to=lambda instance, filename: '%s/%s/item-%s.%s' % (
|
upload_to=itempicture_upload_to
|
||||||
instance.event.organizer.slug, instance.event.slug, instance.identity,
|
|
||||||
filename.split('.')[-1]
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|||||||
Reference in New Issue
Block a user