Commits

Anonymous committed 8944cd2

access options

Comments (0)

Files changed (3)

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)

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>

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>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.