Added forum descriptions. #327
authorEevee <git@veekun.com>
Sun, 15 Aug 2010 02:37:20 +0000 (19:37 -0700)
committerEevee <git@veekun.com>
Sun, 15 Aug 2010 02:37:20 +0000 (19:37 -0700)
migration/versions/004_Add_forum_descriptions.py [new file with mode: 0644]
splinext/forum/model/__init__.py
splinext/forum/templates/css/forum.mako
splinext/forum/templates/forum/forums.mako
splinext/forum/templates/forum/lib.mako
splinext/forum/templates/forum/posts.mako
splinext/forum/templates/forum/threads.mako

diff --git a/migration/versions/004_Add_forum_descriptions.py b/migration/versions/004_Add_forum_descriptions.py
new file mode 100644 (file)
index 0000000..f1a8eef
--- /dev/null
@@ -0,0 +1,25 @@
+from sqlalchemy import *
+from migrate import *
+import migrate.changeset
+
+from sqlalchemy.ext.declarative import declarative_base
+TableBase = declarative_base()
+
+class Forum(TableBase):
+    __tablename__ = 'forums'
+    id = Column(Integer, primary_key=True, autoincrement=True, nullable=False)
+    name = Column(Unicode(133), nullable=False)
+    description = Column(Unicode(1024), nullable=False, default=u'', server_default=u'')
+    access_level = Column(Enum(u'normal', u'soapbox', u'archive', name='forums_access_level'), nullable=False, default=u'normal', server_default=u'normal')
+
+
+def upgrade(migrate_engine):
+    TableBase.metadata.bind = migrate_engine
+
+    # populate_default gets all retarded I don't even
+    Forum.__table__.c.description.create(populate_default=False)
+
+def downgrade(migrate_engine):
+    TableBase.metadata.bind = migrate_engine
+
+    Forum.__table__.c.description.drop()
index f312b4d..37beb61 100644 (file)
@@ -14,6 +14,7 @@ class Forum(TableBase):
     __tablename__ = 'forums'
     id = Column(Integer, primary_key=True, autoincrement=True, nullable=False)
     name = Column(Unicode(133), nullable=False)
+    description = Column(Unicode(1024), nullable=False, default=u'', server_default=u'')
     access_level = Column(Enum(u'normal', u'soapbox', u'archive', name='forums_access_level'), nullable=False, default=u'normal', server_default=u'normal')
 
     def can_create_thread(self, user):
index 0a2244b..dd35bfd 100644 (file)
@@ -4,9 +4,11 @@ ul.forum-hierarchy li { margin: 0.25em; }
 .forum-access-level { font-size: 0.8em; padding: 0.25em 0.625em; font-style: italic; color: #606060; }
 .forum-access-level img { vertical-align: middle; }
 
-table.forum-list { width: 100%; margin-top: 1em; }
+table.forum-list { width: 100%; margin-top: 0.5em; }
+table.forum-list .header-row th { vertical-align: middle; }
 table.forum-list .name { text-align: left; }
 table.forum-list td.name a { display: block; font-size: 1.5em; padding: 0.33em; }
+table.forum-list td.name .forum-description { padding: 0.33em 0.5em; color: #404040; }
 table.forum-list .stats { width: 10em; text-align: center; }
 
 .forum-post-container { }
index 6aa4be3..00310d0 100644 (file)
         <td class="name">
             <a href="${url(controller='forum', action='threads', forum_id=forum.id)}">${forum.name}</a>
             ${forumlib.forum_access_level(forum)}
+            % if forum.description:
+            <div class="forum-description">
+                ${forum.description}
+            </div>
+            % endif
         </td>
         <td class="stats">xxx</td>
         <td class="stats">xxx</th>
index c364c8c..82884f4 100644 (file)
 % endif
 </%def>
 
+## Prints a little hierarchy of context when viewing a thread
+<%def name="hierarchy(forum, thread=None)">
+<ul class="forum-hierarchy">
+<li>
+    % if thread:
+    <a href="${url(controller='forum', action='threads', forum_id=forum.id)}">
+    % else:
+    <strong>
+    % endif
+        <img src="${h.static_uri('spline', 'icons/folders-stack.png')}" alt=""> ${forum.name}
+    % if thread:
+    </a>
+    % else:
+    </strong>
+    % endif
+    % if forum.description:
+    &mdash; ${forum.description}
+    % endif
+    ${forum_access_level(forum)}
+</li>
+% if thread:
+<li>
+    <strong><img src="${h.static_uri('spline', 'icons/folder-open-document-text.png')}" alt=""> ${thread.subject}</strong>
+</li>
+% endif
+</ul>
+</%def>
+
 <%def name="posts(posts)">
 <div class="forum-post-container">
     % for post in posts:
index a0f83e5..773fd9c 100644 (file)
 </%def>
 
 <h1>Posts</h1>
-<ul class="forum-hierarchy">
-    <li>
-        In forum: <a href="${url(controller='forum', action='threads', forum_id=c.thread.forum.id)}"><img src="${h.static_uri('spline', 'icons/folders-stack.png')}" alt=""> ${c.thread.forum.name}</a>
-        ${forumlib.forum_access_level(c.thread.forum)}
-    </li>
-    <li>
-        In thread: <strong><img src="${h.static_uri('spline', 'icons/folder-open-document-text.png')}" alt=""> ${c.thread.subject}</strong>
-    </li>
-</ul>
+${forumlib.hierarchy(c.thread.forum, c.thread)}
 
 % if c.thread.post_count == 0:
 <p>Something terribly bogus has happened; this thread has no posts.</p>
index 3eca688..7df962b 100644 (file)
 </%def>
 
 <h1>Threads</h1>
-<ul class="forum-hierarchy">
-    <li>
-        In forum: <strong><img src="${h.static_uri('spline', 'icons/folders-stack.png')}" alt=""> ${c.forum.name}</strong>
-        ${forumlib.forum_access_level(c.forum)}
-    </li>
-</ul>
+${forumlib.hierarchy(c.forum)}
 
 <table class="forum-list striped-rows">
 <thead>