Super-simple comment display.
authorEevee <git@veekun.com>
Mon, 12 Oct 2009 03:16:04 +0000 (20:16 -0700)
committerEevee <git@veekun.com>
Mon, 12 Oct 2009 03:16:04 +0000 (20:16 -0700)
floof/model/art.py
floof/model/comments.py [new file with mode: 0644]
floof/templates/art/show.mako
floof/templates/comments.mako [new file with mode: 0644]

index 1bde59b..451383b 100644 (file)
@@ -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
 
 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))
 
 class Art(Entity):
     title = Field(Unicode(120))
@@ -20,6 +21,7 @@ class Art(Entity):
 
     uploader = ManyToOne('User', required=True)
     tags = OneToMany('Tag')
 
     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...
 
     # 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"]
 
 
     # 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 (file)
index 0000000..f46b37d
--- /dev/null
@@ -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))
+
index 262f1cb..5895be8 100644 (file)
@@ -1,4 +1,5 @@
 <%inherit file="/base.mako" />
 <%inherit file="/base.mako" />
+<%namespace name="comments" file="/comments.mako" />
 
 <%! from floof.model.art import Rating %>
 
 
 <%! from floof.model.art import Rating %>
 
@@ -33,3 +34,4 @@ ${h.end_form()}
 
 <img class="full" src="${c.art.get_path()}">
 
 
 <img class="full" src="${c.art.get_path()}">
 
+${comments.entire_thread(c.art.discussion)}
diff --git a/floof/templates/comments.mako b/floof/templates/comments.mako
new file mode 100644 (file)
index 0000000..cc59b54
--- /dev/null
@@ -0,0 +1,11 @@
+<%def name="entire_thread(discussion)">
+<%
+    if not discussion:
+        return
+%>\
+<ul>
+    % for comment in discussion.comments:
+    <li>${comment.text}</li>
+    % endfor
+</ul>
+</%def>