posted by me checkbox
authorNick Retallack <nickretallack@gmail.com>
Sun, 6 Dec 2009 06:35:24 +0000 (22:35 -0800)
committerNick Retallack <nickretallack@gmail.com>
Sun, 6 Dec 2009 06:35:24 +0000 (22:35 -0800)
floof/controllers/art.py
floof/templates/art/new.mako

index 5b347b3..9a2f1ba 100644 (file)
@@ -27,6 +27,7 @@ from wtforms import *
 
 class ArtUploadForm(Form):
     by = TextField('Artists')
 
 class ArtUploadForm(Form):
     by = TextField('Artists')
+    by_me = BooleanField('me')
     file = FileField('Upload')
     url = TextField('Link')
 
     file = FileField('Upload')
     url = TextField('Link')
 
@@ -127,8 +128,11 @@ class ArtController(BaseController):
         )
         c.art.discussion = Discussion(count=0)
 
         )
         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:
         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:
 
 
         try:
index 4204700..684c004 100644 (file)
@@ -7,8 +7,12 @@
 
 ${h.form(h.url('create_art'), multipart=True)}
 
 
 ${h.form(h.url('create_art'), multipart=True)}
 
-${normal_field(c.form.by)}
-${normal_field(c.form.file)}
+<div>
+    ${normal_field(c.form.by)}
+    ${checkbox_field(c.form.by_me)}
+</div>
+
+<div>${normal_field(c.form.file)}</div>
 
 
 ##Artist: ${h.text('artist')}
 
 
 ##Artist: ${h.text('artist')}
@@ -17,17 +21,24 @@ ${h.submit(None, 'Upload!')}
 ${h.end_form()}
 
 
 ${h.end_form()}
 
 
+<%def name="field_errors(errors)">
+    %if errors:
+    <ul class="errors">
+        %for error in errors:
+            <li>${error}
+        %endfor
+    </ul>
+    %endif
+</%def>
+
 
 <%def name="normal_field(field)">
 
 <%def name="normal_field(field)">
-<div>
-${field.label()|n}
-${field()|n} 
-%if field.errors:
-<ul class="errors">
-%for error in field.errors:
-<li>${error}
-%endfor
-</ul>
-%endif
-</div>
+    ${field.label()|n}
+    ${field()|n}
+    ${field_errors(field.errors)}
 </%def>
 </%def>
+
+<%def name="checkbox_field(field)">
+    ${field()|n} ${field.label()|n}
+    ${field_errors(field.errors)}
+</%def>
\ No newline at end of file