2018-05-01 02:23:36 +00:00
|
|
|
from django.contrib.auth.models import User
|
2018-04-19 19:52:40 +00:00
|
|
|
from django.db import models
|
2019-04-07 16:04:02 +00:00
|
|
|
from django.utils.translation import ugettext_lazy as _
|
2018-04-19 19:52:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
class BaseFile(models.Model):
|
2019-08-19 21:37:32 +00:00
|
|
|
file = models.FileField(upload_to=".")
|
|
|
|
user = models.ForeignKey(User, related_name="%(class)s", on_delete=models.PROTECT)
|
2018-04-19 19:52:40 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
abstract = True
|
|
|
|
|
2018-04-23 05:15:33 +00:00
|
|
|
def __str__(self):
|
|
|
|
return self.file.name
|
|
|
|
|
2018-10-12 22:30:47 +00:00
|
|
|
def name(self):
|
|
|
|
return self.file.name
|
|
|
|
|
2018-04-19 19:52:40 +00:00
|
|
|
|
|
|
|
class File(BaseFile):
|
|
|
|
pass
|
2018-05-30 03:14:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ImageFile(BaseFile):
|
|
|
|
caption = models.CharField(
|
2019-08-19 21:37:32 +00:00
|
|
|
verbose_name=_("Image caption"), max_length=240, blank=True
|
2018-05-30 03:14:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
credit = models.CharField(
|
2019-08-19 21:37:32 +00:00
|
|
|
verbose_name=_("Image credit"), max_length=240, blank=True
|
2018-05-30 03:14:36 +00:00
|
|
|
)
|