From c472ed30b5d4600a8ead8846ddbcbf3bb1b027d6 Mon Sep 17 00:00:00 2001 From: Nick Retallack Date: Sat, 5 Dec 2009 22:35:24 -0800 Subject: [PATCH 1/1] posted by me checkbox --- floof/controllers/art.py | 6 +++++- floof/templates/art/new.mako | 37 ++++++++++++++++++++++++------------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/floof/controllers/art.py b/floof/controllers/art.py index 5b347b3..9a2f1ba 100644 --- a/floof/controllers/art.py +++ b/floof/controllers/art.py @@ -27,6 +27,7 @@ from wtforms import * class ArtUploadForm(Form): by = TextField('Artists') + by_me = BooleanField('me') file = FileField('Upload') url = TextField('Link') @@ -127,8 +128,11 @@ class ArtController(BaseController): ) c.art.discussion = Discussion(count=0) + if c.form.by_me and c.user not in c.form.by.data: + UserRelation(user=c.user, creator=c.user, kind="by", art=c.art) + for artist in c.form.by.data: - UserRelation(user=artist, kind="by", creator=c.user, art=c.art) + UserRelation(user=artist, creator=c.user, kind="by", art=c.art) try: diff --git a/floof/templates/art/new.mako b/floof/templates/art/new.mako index 4204700..684c004 100644 --- a/floof/templates/art/new.mako +++ b/floof/templates/art/new.mako @@ -7,8 +7,12 @@ ${h.form(h.url('create_art'), multipart=True)} -${normal_field(c.form.by)} -${normal_field(c.form.file)} +
+ ${normal_field(c.form.by)} + ${checkbox_field(c.form.by_me)} +
+ +
${normal_field(c.form.file)}
##Artist: ${h.text('artist')} @@ -17,17 +21,24 @@ ${h.submit(None, 'Upload!')} ${h.end_form()} +<%def name="field_errors(errors)"> + %if errors: + + %endif + + <%def name="normal_field(field)"> -
-${field.label()|n} -${field()|n} -%if field.errors: - -%endif -
+ ${field.label()|n} + ${field()|n} + ${field_errors(field.errors)} + +<%def name="checkbox_field(field)"> + ${field()|n} ${field.label()|n} + ${field_errors(field.errors)} + \ No newline at end of file -- 2.7.4