X-Git-Url: http://git.veekun.com/zzz-floof.git/blobdiff_plain/dcf6146e9914ff3c166f242b72f04a8934d65148..b07336c562d537ea3407d6a1c9fcb280dae7f514:/floof/model/art.py diff --git a/floof/model/art.py b/floof/model/art.py index 8989e8f..ea6d6ee 100644 --- a/floof/model/art.py +++ b/floof/model/art.py @@ -4,7 +4,6 @@ # Copyright (c) 2009 Scribblr # -# from elixir import Entity, Field, Integer, Unicode from elixir import * import elixir @@ -12,12 +11,9 @@ from pylons import config from floof.lib.file_storage import get_path, save_file from floof.lib.dbhelpers import find_or_create, update_or_create -import floof.model.comments +from floof.model.users import User -# Note: Art is the most important class. To keep its size down, and to better organize the source code, -# other modules will mix into it automatically by adding to its __bases__. - class Art(Entity): title = Field(Unicode(120)) original_filename = Field(Unicode(120)) @@ -28,8 +24,36 @@ class Art(Entity): tags = OneToMany('Tag') discussion = ManyToOne('Discussion') - user_relations = OneToMany('UserRelation') + art_users = OneToMany('ArtUser') @property def file_path(self): return get_path("art", self.hash) + + # Associated users + # XXX ok these could stand to do the filtering sql-side + @property + def artists(self): + return (au.user for au in self.art_users if au.type == ArtUserType.BY) + + @property + def recipients(self): + return (au.user for au in self.art_users if au.type == ArtUserType.FOR) + + @property + def participants(self): + return (au.user for au in self.art_users if au.type == ArtUserType.OF) + + +class ArtUserType(object): + BY = 1 + FOR = 2 + OF = 3 + +class ArtUser(Entity): + art = ManyToOne('Art', required=True) + user = ManyToOne('User', required=True) + type = Field(Integer, required=True) # ArtUserType + + # TODO: admin log ought to remember who confirmed the relation. + # (tag history will remember who proposed it)