From: Eevee Date: Fri, 23 Oct 2009 02:31:14 +0000 (-0700) Subject: Merge branch 'comments' X-Git-Url: http://git.veekun.com/zzz-floof.git/commitdiff_plain/7c20a2661d532fe1e338f0f0dfb9fe42113ab103?hp=-c Merge branch 'comments' --- 7c20a2661d532fe1e338f0f0dfb9fe42113ab103 diff --combined floof/controllers/art.py index fea21c6,9576109..d598292 --- a/floof/controllers/art.py +++ b/floof/controllers/art.py @@@ -9,6 -9,7 +9,7 @@@ log = logging.getLogger(__name__ import elixir from floof.model.art import Art, Rating + from floof.model.comments import Discussion from sqlalchemy.exceptions import IntegrityError @@@ -20,6 -21,10 +21,6 @@@ class ArtController(BaseController) if id: c.art = h.get_object_or_404(Art, id=id) - # def index(): - # c.artwork = Art.query.order_by(Art.id.desc()).all() - # return render - def new(self): """ New Art! """ return render("/art/new.mako") @@@ -27,6 -32,7 +28,7 @@@ # TODO: login required def create(self): c.art = Art(uploader=c.user, **request.params) + c.art.discussion = Discussion(count=0) try: elixir.session.commit() diff --combined floof/model/art.py index c21c74a,451383b..0732684 --- 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,7 -21,18 +21,8 @@@ uploader = ManyToOne('User', required=True) tags = OneToMany('Tag') + discussion = ManyToOne('Discussion') - # 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. - def set_file(self, file): self.hash = save_file("art", file) self.original_filename = file.filename @@@ -73,6 -85,15 +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)" @@@ -92,8 -113,12 +94,8 @@@ class Rating(Entity) 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()))