expephalon/core/models/files.py
Klaus-Uwe Mitterer 2e8bbdd8a7 A lot of new views
Color picker fields
Renamed pixel.png in order not to upset uBlock...
2020-06-02 17:58:20 +02:00

35 lines
No EOL
956 B
Python

from django.db.models import Model, ImageField, FileField, ManyToManyField, ForeignKey, BooleanField, CASCADE
from django.contrib.auth import get_user_model
from polymorphic.models import PolymorphicModel
from core.helpers.files import generate_storage_filename
from core.models.profiles import Profile
from core.fields.base import LongCharField
# Create your models here.
class BaseFile(PolymorphicModel):
filename = LongCharField()
def __str__(self):
return self.filename
class ImageFile(BaseFile):
rawfile = ImageField(upload_to=generate_storage_filename)
@property
def get_file(self):
return self.rawfile
class File(BaseFile):
rawfile = FileField(upload_to=generate_storage_filename)
@property
def get_file(self):
return self.rawfile
class FileAssociation(Model):
file = ForeignKey(BaseFile, CASCADE)
user = ForeignKey(get_user_model(), CASCADE)
visible = BooleanField()