Commits

danjac  committed 8944cd2

access options

  • Participants
  • Parent commits 9b29af8

Comments (0)

Files changed (3)

File newsmeme/forms.py

 import re
 
 from flaskext.wtf import Form, TextField, PasswordField, HiddenField, \
-    BooleanField, RecaptchaField, TextAreaField, ValidationError, \
+    BooleanField, RadioField, RecaptchaField, TextAreaField, ValidationError, \
     required, email, equal_to, url, optional, regexp
 
 from flaskext.babel import gettext, lazy_gettext as _
 
     tags = TextField(_("Tags"))
 
+    access = RadioField(_("Who can see this post ?"), 
+                        default=Post.PUBLIC, 
+                        coerce=int,
+                        choices=((Post.PUBLIC, _("Everyone")),
+                                 (Post.FRIENDS, _("Friends only")),
+                                 (Post.PRIVATE, _("Just myself"))))
+
     def __init__(self, *args, **kwargs):
         self.post = kwargs.get('obj', None)
         super(PostForm, self).__init__(*args, **kwargs)

File newsmeme/templates/post/edit_post.html

             {{ form.description(rows=6, cols=30) }}
         </li>
         <li>
+            {{ render_errors(form.access) }}
+            {{ form.access.label }}<br>
+            {% for option in form.access %}
+            {{ option }} {{ option.label(class_="checkbox") }} 
+            {% endfor %}
+        </li>
+        <li>
         <input type="submit" value="{{ _('Save') }}">
         </li>
         <li>

File newsmeme/templates/submit.html

             {{ form.description(rows=6, cols=30) }}
         </li>
         <li>
+            {{ render_errors(form.access) }}
+            {{ form.access.label }}<br>
+            {% for option in form.access %}
+            {{ option }} {{ option.label(class_="checkbox") }} 
+            {% endfor %}
+        </li>
+        <li>
             <input type="submit" value="Submit">
             </li>
             <li>