From 5bf90b6e04207ae9e2b43eafe459c9c4a01edf06 Mon Sep 17 00:00:00 2001 From: Fahrezal Effendi Date: Thu, 18 Feb 2010 17:44:21 +0700 Subject: [PATCH] Post creation. Needs re-think. --- townsquare/controllers/post.py | 14 +++++++++++--- townsquare/model/post.py | 2 +- townsquare/public/quick.css | 12 ++++++++++++ townsquare/templates/base.mako | 3 ++- townsquare/templates/channel/view.mako | 8 +++++++- townsquare/templates/post/edit.mako | 6 +++++- townsquare/templates/post/list-embed.mako | 3 +++ townsquare/templates/user/view.mako | 2 +- 8 files changed, 42 insertions(+), 8 deletions(-) diff --git a/townsquare/controllers/post.py b/townsquare/controllers/post.py index 6d78105..d51c45c 100644 --- a/townsquare/controllers/post.py +++ b/townsquare/controllers/post.py @@ -37,6 +37,14 @@ class PostController(BaseController): if u is None: redirect_to(user.create_login_url('')) + c.new_post = False + if idname is None or len(idname) is 0: + c.new_post = True + try: c.host_classname = request.GET.getone('host_classname').strip() + except: pass + try: c.host_id = request.GET.getone('host_id').strip() + except: pass + c.field_errors = [] form_valid = False @@ -55,7 +63,7 @@ class PostController(BaseController): c.channels = request.POST.getone('channels').strip() except: pass try: - c.host_metaname = request.POST.getone('host_metaname').strip() + c.host_classname = request.POST.getone('host_classname').strip() except: pass try: c.host_id = request.POST.getone('host_id').strip() @@ -92,8 +100,8 @@ class PostController(BaseController): # if ch is not None: # post.channels.append(str(ch._id)) - if len(c.host_metaname) and len(c.host_id): - cl = globals()[c.host_metaname] + if len(c.host_classname) and len(c.host_id): + cl = globals()[c.host_classname] #TODO: catch exception host = g.db.col(cl).find_one(_id=c.host_id) #TODO: check acl and role diff --git a/townsquare/model/post.py b/townsquare/model/post.py index 2efe464..d1b4909 100644 --- a/townsquare/model/post.py +++ b/townsquare/model/post.py @@ -92,7 +92,7 @@ class Post(SuperDoc): self._host_classname = self.host.__class__.__name__ self._host_id = str(self.host._id) else: - if hasattr(self, '_host_metaname'): + if hasattr(self, '_host_classname'): self._host_classname = '' #TODO: delete property if hasattr(self, '_host_id'): self._host_id = '' #TODO: delete property diff --git a/townsquare/public/quick.css b/townsquare/public/quick.css index 797d28c..153088f 100644 --- a/townsquare/public/quick.css +++ b/townsquare/public/quick.css @@ -30,6 +30,18 @@ img { color:#999999; } +ul.inline-list { + list-style:none; + display:inline; + margin:0; + padding:0; +} +ul.inline-list li { + display:inline; + margin:0 1em; +/* padding:.4em;*/ +} + .page-top { background-color:#eaeaea; diff --git a/townsquare/templates/base.mako b/townsquare/templates/base.mako index a06cb71..d8c97af 100644 --- a/townsquare/templates/base.mako +++ b/townsquare/templates/base.mako @@ -11,9 +11,10 @@
diff --git a/townsquare/templates/channel/view.mako b/townsquare/templates/channel/view.mako index 3fc9faa..670dc99 100644 --- a/townsquare/templates/channel/view.mako +++ b/townsquare/templates/channel/view.mako @@ -9,15 +9,21 @@ ${h.literal(c.ch.description)}
${h.secure_form(url('/posts/create'))} +
Post a shout
${h.textarea(name='content', rows=7, cols=40, content=c.content)}
${h.submit(value='Post', name='commit')} ${h.hidden(name='channels', value=c.ch._id)} - ${h.hidden(name='host_metaname', value=c.ch._metaname_)} + ${h.hidden(name='host_classname', value=c.ch.__class__.__name__)} ${h.hidden(name='host_id', value=c.ch._id)} ${h.hidden(name='success_redirect', value=c.ch.url)}
${h.end_form()} +
diff --git a/townsquare/templates/post/edit.mako b/townsquare/templates/post/edit.mako index 83b5c04..c0e7891 100644 --- a/townsquare/templates/post/edit.mako +++ b/townsquare/templates/post/edit.mako @@ -5,7 +5,7 @@
${h.secure_form(url(''))}
-% if c.title and len(c.title): +% if c.new_post or (c.title and len(c.title)):
Title
${h.text(name='title', value=c.title, maxLength=255)} @@ -24,6 +24,10 @@ ${h.secure_form(url(''))} % if c.redir and len(c.redir): ${h.hidden(name='success_redirect', value=c.redir)} % endif +% if len(c.host_classname) and len(c.host_id): + ${h.hidden(name='host_classname', value=c.host_classname)} + ${h.hidden(name='host_id', value=c.host_id)} +% endif
${h.end_form()} diff --git a/townsquare/templates/post/list-embed.mako b/townsquare/templates/post/list-embed.mako index 5746b57..beb1236 100644 --- a/townsquare/templates/post/list-embed.mako +++ b/townsquare/templates/post/list-embed.mako @@ -11,6 +11,9 @@ &bull delete
+% if hasattr(p, 'name') and len(p.name): +

${p.name}

+% endif % if hasattr(p, 'deletion_status') and p.deletion_status is True:

DELETED % else: diff --git a/townsquare/templates/user/view.mako b/townsquare/templates/user/view.mako index dd21d53..d08ee07 100644 --- a/townsquare/templates/user/view.mako +++ b/townsquare/templates/user/view.mako @@ -10,7 +10,7 @@ ${h.secure_form(url('/posts/create'))}

${h.submit(value='Post', name='commit')} ${h.hidden(name='channels', value=c.user._id)} - ${h.hidden(name='host_metaname', value=c.user._metaname_)} + ${h.hidden(name='host_classname', value=c.user.__class__.__name__)} ${h.hidden(name='host_id', value=c.user._id)} ${h.hidden(name='success_redirect', value=c.user.url)}
-- 2.11.4.GIT