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