ojuso-map/apps/files/models.py
Anna Sidwell 79dffadd14 Restore names of uploaded files on submit/draft restore (#65)
This involved turning the list of file IDs stored in the hidden
text field into JSON.
2018-10-12 18:34:39 -04:00

42 lines
797 B
Python

from django.contrib.auth.models import User
from django.db import models
from django.utils.translation import ugettext as _
from apps.map.models import CaseStudy, CaseStudyDraft
class BaseFile(models.Model):
file = models.FileField(
upload_to='.',
)
user = models.ForeignKey(
User, related_name='%(class)s'
)
class Meta:
abstract = True
def __str__(self):
return self.file.name
def name(self):
return self.file.name
class File(BaseFile):
pass
class ImageFile(BaseFile):
caption = models.CharField(
verbose_name=_("Image caption"),
max_length=240,
blank=True,
)
credit = models.CharField(
verbose_name=_("Image credit"),
max_length=240,
blank=True,
)