adding new art with user relations is there, sort of. Still needs adding relations...
[zzz-floof.git] / floof / model / art.py
1 #
2 # floof/floof/model/art.py
3 #
4 # Copyright (c) 2009 Scribblr
5 #
6
7 # from elixir import Entity, Field, Integer, Unicode
8 from elixir import *
9 import elixir
10
11 from pylons import config
12
13 from floof.lib.file_storage import get_path, save_file
14 from floof.lib.dbhelpers import find_or_create, update_or_create
15 import floof.model.comments
16
17
18 # Note: Art is the most important class. To keep its size down, and to better organize the source code,
19 # other modules will mix into it automatically by adding to its __bases__.
20
21 class Art(Entity):
22 title = Field(Unicode(120))
23 original_filename = Field(Unicode(120))
24 hash = Field(String, unique=True, required=True)
25
26 uploader = ManyToOne('User', required=True)
27 tags = OneToMany('Tag')
28 discussion = ManyToOne('Discussion')
29
30 user_relations = OneToMany('UserRelation')
31
32
33 def set_file(self, file):
34 self.hash = save_file("art", file)
35 self.original_filename = file.filename
36
37 file = property(get_path, set_file)
38
39 def get_path(self):
40 if self.hash:
41 return get_path("art", self.hash)
42
43 def __unicode__(self):
44 return self.get_path()