Add: base submission file model
This commit is contained in:
parent
e2e4994954
commit
e24d017082
1 changed files with 22 additions and 0 deletions
22
archivist/apps/files/models.py
Normal file
22
archivist/apps/files/models.py
Normal 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
|
Loading…
Reference in a new issue