From: Eevee Date: Mon, 12 Oct 2009 03:16:04 +0000 (-0700) Subject: Super-simple comment display. X-Git-Url: http://git.veekun.com/zzz-floof.git/commitdiff_plain/422dfbb85e3efd51efd676779012aeb3f9575ba4?ds=sidebyside;hp=03afe6343d8d8d5547074999b85a7b2d1fe2f428 Super-simple comment display. --- diff --git a/floof/model/art.py b/floof/model/art.py index 1bde59b..451383b 100644 --- a/floof/model/art.py +++ b/floof/model/art.py @@ -12,6 +12,7 @@ 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 class Art(Entity): title = Field(Unicode(120)) @@ -20,6 +21,7 @@ class Art(Entity): 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... @@ -119,4 +121,4 @@ class Rating(Entity): # options = ["sucks","neutral","good","great"] -Rating.reverse_options = dict (zip(Rating.options.values(), Rating.options.keys())) \ No newline at end of file +Rating.reverse_options = dict (zip(Rating.options.values(), Rating.options.keys())) diff --git a/floof/model/comments.py b/floof/model/comments.py new file mode 100644 index 0000000..f46b37d --- /dev/null +++ b/floof/model/comments.py @@ -0,0 +1,11 @@ +from elixir import * + +class Discussion(Entity): + """Represents a collection of comments attached to some other object.""" + count = Field(Integer) + comments = OneToMany('Comment') + +class Comment(Entity): + discussion = ManyToOne('Discussion') + text = Field(Unicode(65536)) + diff --git a/floof/templates/art/show.mako b/floof/templates/art/show.mako index 262f1cb..5895be8 100644 --- a/floof/templates/art/show.mako +++ b/floof/templates/art/show.mako @@ -1,4 +1,5 @@ <%inherit file="/base.mako" /> +<%namespace name="comments" file="/comments.mako" /> <%! from floof.model.art import Rating %> @@ -33,3 +34,4 @@ ${h.end_form()} +${comments.entire_thread(c.art.discussion)} diff --git a/floof/templates/comments.mako b/floof/templates/comments.mako new file mode 100644 index 0000000..cc59b54 --- /dev/null +++ b/floof/templates/comments.mako @@ -0,0 +1,11 @@ +<%def name="entire_thread(discussion)"> +<% + if not discussion: + return +%>\ + +