bb68c9f8dab4341f413ce9a4965e21beec916205
2 # floof/floof/model/art.py
4 # Copyright (c) 2009 Scribblr
7 # from elixir import Entity, Field, Integer, Unicode
11 from pylons
import config
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
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__.
22 title
= Field(Unicode(120))
23 original_filename
= Field(Unicode(120))
24 hash = Field(String
, unique
=True, required
=True)
26 uploader
= ManyToOne('User', required
=True)
27 tags
= OneToMany('Tag')
28 discussion
= ManyToOne('Discussion')
30 user_relations
= OneToMany('UserRelation')
33 def set_file(self
, file):
34 self
.hash = save_file("art", file)
35 self
.original_filename
= file.filename
37 file = property(get_path
, set_file
)
41 return get_path("art", self
.hash)
43 def __unicode__(self
):
44 return self
.get_path()