1. Benjamin Klüglein
  2. datenaustausch

Commits

Benjamin Klüglein  committed 18c2167

Added fields

  • Participants
  • Parent commits 9d41176
  • Branches upload_ticket

Comments (0)

Files changed (2)

File upload/admin.py

View file
-from datenaustausch.upload.models import File
+from datenaustausch.upload.models import *
 from django.contrib import admin
 
 admin.site.register(File)
+admin.site.register(UploadTicket)
 

File upload/models.py

View file
 from django.db import models
 from django.contrib.auth.models import User
 
+from hashlib import md5
 from os import path
 
+import time
+
 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")
+    created_at = models.DateTimeField("Created at", auto_now=True)
     file_on_fs = models.FileField(upload_to="uploads")
     download_password = models.CharField(max_length=64, blank=True)
 
         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)
+    referenced_file = models.ForeignKey(File, null=True, blank=True)
+    identifier = models.CharField(max_length=48, blank=True, unique=True)
     created_by = models.ForeignKey(User)
+    created_at = models.DateTimeField("Created at", auto_now=True)
+    valid_until = models.DateTimeField("Valid until", blank=True)
+    
+    def is_occupied(self):
+        pass
+
+    @classmethod
+    def generate_new_id(cls):
+        return md5(str(time.time())).hexdigest()
+        
+