8989e8fcffcf82f522539ff64185589ce45f23d6
[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(Unicode(40), unique=True, required=True)
25 mimetype = Field(Unicode(32), required=True)
26
27 uploader = ManyToOne('User', required=True)
28 tags = OneToMany('Tag')
29 discussion = ManyToOne('Discussion')
30
31 user_relations = OneToMany('UserRelation')
32
33 @property
34 def file_path(self):
35 return get_path("art", self.hash)