Thumbnailing.
[zzz-floof.git] / floof / model / art.py
index bb68c9f..8989e8f 100644 (file)
@@ -21,7 +21,8 @@ import floof.model.comments
 class Art(Entity):
     title = Field(Unicode(120))
     original_filename = Field(Unicode(120))
-    hash = Field(String, unique=True, required=True)
+    hash = Field(Unicode(40), unique=True, required=True)
+    mimetype = Field(Unicode(32), required=True)
 
     uploader = ManyToOne('User', required=True)
     tags = OneToMany('Tag')
@@ -29,16 +30,6 @@ class Art(Entity):
 
     user_relations = OneToMany('UserRelation')
 
-
-    def set_file(self, file):
-        self.hash = save_file("art", file)
-        self.original_filename = file.filename
-
-    file = property(get_path, set_file)
-
-    def get_path(self):
-        if self.hash:
-            return get_path("art", self.hash)
-
-    def __unicode__(self):
-        return self.get_path()
+    @property
+    def file_path(self):
+        return get_path("art", self.hash)