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))
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...
# 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()))
--- /dev/null
+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))
+
<%inherit file="/base.mako" />
+<%namespace name="comments" file="/comments.mako" />
<%! from floof.model.art import Rating %>
<img class="full" src="${c.art.get_path()}">
+${comments.entire_thread(c.art.discussion)}
--- /dev/null
+<%def name="entire_thread(discussion)">
+<%
+ if not discussion:
+ return
+%>\
+<ul>
+ % for comment in discussion.comments:
+ <li>${comment.text}</li>
+ % endfor
+</ul>
+</%def>