From: Nick Retallack Date: Sat, 24 Oct 2009 05:00:00 +0000 (-0700) Subject: merged in comments X-Git-Url: http://git.veekun.com/zzz-floof.git/commitdiff_plain/f267b2f2841d407dcdf9c3c0f5406f8c10403ccb?hp=-c merged in comments --- f267b2f2841d407dcdf9c3c0f5406f8c10403ccb diff --combined floof/model/art.py index 544a830,0732684..8b328d8 --- a/floof/model/art.py +++ b/floof/model/art.py @@@ -12,6 -12,7 +12,7 @@@ from pylons import confi 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 class Art(Entity): title = Field(Unicode(120)) @@@ -20,16 -21,7 +21,7 @@@ uploader = ManyToOne('User', required=True) tags = OneToMany('Tag') - - # def __init__(self, **kwargs): - # # I wanted to check for the existence of the file, but... - # # for some reason this FieldStorage object always conditions as falsey. - # # self.hash = save_file("art", kwargs.pop('file')) - # super(Art, self).__init__(**kwargs) - # # this is what super is doing, pretty much. - # # for key, value in kwargs.items(): - # # setattr(self, key, value) - # left for posterity. + discussion = ManyToOne('Discussion') def set_file(self, file): self.hash = save_file("art", file) @@@ -52,7 -44,7 +44,7 @@@ if tag: elixir.session.delete(tag) - else: + else: if len(text) > 50: raise "Long Tag!" # can we handle this more gracefully? # sqlite seems happy to store strings much longer than the supplied limit... @@@ -66,7 -58,7 +58,7 @@@ def rate(self, score, user): return update_or_create(Rating, {"rater":user, "art":self}, {"score":score}) - + def user_score(self, user): rating = Rating.get_by(rater=user, art=self) if rating: @@@ -83,15 -75,6 +75,6 @@@ class Tag(Entity) tagger = ManyToOne('User', ondelete='cascade') tagtext = ManyToOne('TagText') - # this text setter is no longer useful since I changed the way Art#add_tags works - # but I'll leave it in here just for several minutes nostalgia. - # def set_text(self, text): - # self.tagtext = TagText.get_by(text=text) - # if not self.tagtext: - # self.tagtext = TagText(text=text) - # - # text = property(lambda self: self.tagtext.text, set_text) - def __unicode__(self): if not self.tagtext: return "(broken)" @@@ -104,31 -87,15 +87,25 @@@ class TagText(Entity) def __unicode__(self): return self.text - + class Rating(Entity): art = ManyToOne('Art', ondelete='cascade') rater = ManyToOne('User', ondelete='cascade') score = Field(Integer) - - # @score.setter - # def score(self, value): - + options = {-1:"sucks", 0:"undecided", 1:"good", 2:"great"} default = 0 - # options = ["sucks","neutral","good","great"] - - Rating.reverse_options = dict (zip(Rating.options.values(), Rating.options.keys())) + + + - +class UserRelation(Entity): + related = ManyToOne("User") + art = ManyToOne("Art") + type = Field(String) # by for of + + +# class CharacterRelation(Entity): - # pass ++# pass diff --combined floof/model/search.py index a413eb6,01d45a2..2296491 --- a/floof/model/search.py +++ b/floof/model/search.py @@@ -6,11 -6,10 +6,11 @@@ from floof.lib.search import do_searc class SavedSearch(Entity): string = Field(Unicode) # I tried calling this query, but it broke elixir author = ManyToOne('User') + fork = ManyToOne("SavedSearch") - + def __unicode__(self): return self.string - + @property def results(self): return do_search(self.string) @@@ -24,19 -23,18 +24,18 @@@ class GalleryWidget(Entity) # NOTE: no longer needed now that we have pages, I guess. # displayer = ManyToOne('User') # determines whose page should it should show up on # # Could be no-ones, if it's just a template. - + # Needs some fields for position on your page @property def string(self): return self.search - + @string.setter def string(self, value): # TODO: should we delete the possibly orphaned saved search? # if not self.displayer: # # TODO: may have to refactor this into an init if the key ordering is inconvenienc # raise "Oh no! This gallery needs a displayer to set on the saved search." - + self.search = SavedSearch(author=getattr(self,"author",None), string=value) - diff --combined floof/model/users.py index 2775ab7,e2afd17..c38197c --- a/floof/model/users.py +++ b/floof/model/users.py @@@ -17,18 -17,18 +17,18 @@@ class User(Entity) pages = OneToMany('UserPage', inverse="owner") primary_page = OneToOne('UserPage', inverse="owner") - + def __unicode__(self): return self.name def __init__(self, **kwargs): super(User, self).__init__(**kwargs) - - - + + + # TODO: have this clone a standard starter page self.primary_page = UserPage(owner=self, title="default", visible=True) - + # a starter gallery, just for fun gallery = GalleryWidget(owner=self, string="awesome") self.primary_page.galleries.append(gallery) @@@ -45,18 -45,12 +45,17 @@@ class UserPage(Entity) This is so that they can keep some nice themed pages lying around for special occasions. Page templates that provide familiar interfaces will also be UserPage records. Users will see a panel full of them, and they can choose to clone those template pages to their own page list. - If more than one is set to visible, there would be tabs. - - """ - + If more than one is set to visible, there would be tabs. The primary page is indicated in the user model. - + """ + owner = ManyToOne('User', inverse="pages") title = Field(String) - + visible = Field(Boolean) - galleries = OneToMany('GalleryWidget') + galleries = OneToMany('GalleryWidget') + + + + +# class ArtRelation(Entity): +#