From ada04281f0d79218f32415acf570a627dc68bde7 Mon Sep 17 00:00:00 2001 From: Eevee Date: Sat, 14 Aug 2010 19:37:20 -0700 Subject: [PATCH 1/1] Added forum descriptions. #327 --- migration/versions/004_Add_forum_descriptions.py | 25 +++++++++++++++++++++ splinext/forum/model/__init__.py | 1 + splinext/forum/templates/css/forum.mako | 4 +++- splinext/forum/templates/forum/forums.mako | 5 +++++ splinext/forum/templates/forum/lib.mako | 28 ++++++++++++++++++++++++ splinext/forum/templates/forum/posts.mako | 10 +-------- splinext/forum/templates/forum/threads.mako | 7 +----- 7 files changed, 64 insertions(+), 16 deletions(-) create mode 100644 migration/versions/004_Add_forum_descriptions.py diff --git a/migration/versions/004_Add_forum_descriptions.py b/migration/versions/004_Add_forum_descriptions.py new file mode 100644 index 0000000..f1a8eef --- /dev/null +++ b/migration/versions/004_Add_forum_descriptions.py @@ -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() diff --git a/splinext/forum/model/__init__.py b/splinext/forum/model/__init__.py index f312b4d..37beb61 100644 --- a/splinext/forum/model/__init__.py +++ b/splinext/forum/model/__init__.py @@ -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): diff --git a/splinext/forum/templates/css/forum.mako b/splinext/forum/templates/css/forum.mako index 0a2244b..dd35bfd 100644 --- a/splinext/forum/templates/css/forum.mako +++ b/splinext/forum/templates/css/forum.mako @@ -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 { } diff --git a/splinext/forum/templates/forum/forums.mako b/splinext/forum/templates/forum/forums.mako index 6aa4be3..00310d0 100644 --- a/splinext/forum/templates/forum/forums.mako +++ b/splinext/forum/templates/forum/forums.mako @@ -21,6 +21,11 @@ ${forum.name} ${forumlib.forum_access_level(forum)} + % if forum.description: +
+ ${forum.description} +
+ % endif xxx xxx diff --git a/splinext/forum/templates/forum/lib.mako b/splinext/forum/templates/forum/lib.mako index c364c8c..82884f4 100644 --- a/splinext/forum/templates/forum/lib.mako +++ b/splinext/forum/templates/forum/lib.mako @@ -13,6 +13,34 @@ % endif +## Prints a little hierarchy of context when viewing a thread +<%def name="hierarchy(forum, thread=None)"> + + + <%def name="posts(posts)">
% for post in posts: diff --git a/splinext/forum/templates/forum/posts.mako b/splinext/forum/templates/forum/posts.mako index a0f83e5..773fd9c 100644 --- a/splinext/forum/templates/forum/posts.mako +++ b/splinext/forum/templates/forum/posts.mako @@ -12,15 +12,7 @@

Posts

- +${forumlib.hierarchy(c.thread.forum, c.thread)} % if c.thread.post_count == 0:

Something terribly bogus has happened; this thread has no posts.

diff --git a/splinext/forum/templates/forum/threads.mako b/splinext/forum/templates/forum/threads.mako index 3eca688..7df962b 100644 --- a/splinext/forum/templates/forum/threads.mako +++ b/splinext/forum/templates/forum/threads.mako @@ -11,12 +11,7 @@

Threads

- +${forumlib.hierarchy(c.forum)} -- 2.7.4