Add: base submission file model

This commit is contained in:
Aroy-Art 2023-12-28 17:38:25 +01:00
parent e2e4994954
commit e24d017082
Signed by: Aroy
GPG key ID: 583642324A1D2070

View file

@ -0,0 +1,22 @@
from django.db import models
from django.utils.translation import gettext_lazy as _
# Create your models here.
def get_upload_to(instance, filename):
return f'submissions/{instance.file_hash[:2]}/{filename}'
class Submission_File(models.Model):
file_hash = models.CharField(unique=True, max_length=64,)
file_name = models.CharField(max_length=150, blank=True)
file = models.FileField(upload_to=get_upload_to, blank=True)
date_added = models.DateTimeField(auto_now_add=True, editable=True)
class Meta:
verbose_name = _("Submission File")
verbose_name_plural = _("Submission Files")
def __str__(self):
return self.file_hash