Source

datenaustausch / upload / models.py

Full commit
from django.db import models
from django.contrib.auth.models import User

from os import path

class File(models.Model):
    owner = models.ForeignKey(User)
    name = models.CharField(max_length=128, blank=False, null=False)
    description = models.TextField(max_length=512)
    created_at = models.DateTimeField("Created at")
    file_on_fs = models.FileField(upload_to="uploads")
    download_password = models.CharField(max_length=64, blank=True)

    def is_password_protected(self):
        return any(self.download_password )
    
    def filename(self):
        return path.basename(self.file_on_fs.name)

class UploadTicket(models.Model):
    referenced_file = models.ForeignKey(File)
    identifier = models.CharField(max_length=32, blank=False)
    created_by = models.ForeignKey(User)