From e24d017082e30efe8b331f0d38aeec3d593f944d Mon Sep 17 00:00:00 2001 From: Aroy-Art Date: Thu, 28 Dec 2023 17:38:25 +0100 Subject: [PATCH] Add: base submission file model --- archivist/apps/files/models.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 archivist/apps/files/models.py diff --git a/archivist/apps/files/models.py b/archivist/apps/files/models.py new file mode 100644 index 0000000..7d1abbf --- /dev/null +++ b/archivist/apps/files/models.py @@ -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