changeset 2177:98af52a80d21

user subscriptions settings
author Ana Balica <ana.balica@gmail.com>
date Mon, 26 Aug 2013 19:24:07 +0300
parents 7b78960fc720
children 2c7cad827dcb
files MoinMoin/apps/frontend/views.py MoinMoin/forms.py MoinMoin/templates/usersettings_ajax.html MoinMoin/templates/usersettings_forms.html
diffstat 4 files changed, 33 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/views.py	Wed Aug 21 17:00:14 2013 +0300
+++ b/MoinMoin/apps/frontend/views.py	Mon Aug 26 19:24:07 2013 +0300
@@ -46,8 +46,9 @@
 from MoinMoin.i18n import _, L_, N_
 from MoinMoin.themes import render_template, contenttype_to_class
 from MoinMoin.apps.frontend import frontend
-from MoinMoin.forms import (OptionalText, RequiredText, URL, YourOpenID, YourEmail, RequiredPassword, Checkbox,
-                            InlineCheckbox, Select, Names, Tags, Natural, Hidden, MultiSelect, Enum)
+from MoinMoin.forms import (OptionalText, RequiredText, URL, YourOpenID, YourEmail,
+                            RequiredPassword, Checkbox, InlineCheckbox, Select, Names,
+                            Tags, Natural, Hidden, MultiSelect, Enum, Subscriptions)
 from MoinMoin.items import BaseChangeForm, Item, NonExistent, NameNotUniqueError
 from MoinMoin.items.content import content_registry
 from MoinMoin import user, util
@@ -1492,6 +1493,12 @@
     submit_label = L_('Save')
 
 
+class UserSettingsSubscriptionsForm(Form):
+    name = 'usersettings_subscriptions'
+    subscriptions = Subscriptions
+    submit_label = L_('Save')
+
+
 @frontend.route('/+usersettings', methods=['GET', 'POST'])
 def usersettings():
     # TODO use ?next=next_location check if target is in the wiki and not outside domain
@@ -1531,6 +1538,7 @@
         ui=UserSettingsUIForm,
         navigation=UserSettingsNavigationForm,
         options=UserSettingsOptionsForm,
+        subscriptions=UserSettingsSubscriptionsForm,
     )
     forms = dict()
 
--- a/MoinMoin/forms.py	Wed Aug 21 17:00:14 2013 +0300
+++ b/MoinMoin/forms.py	Mon Aug 26 19:24:07 2013 +0300
@@ -29,6 +29,9 @@
 from MoinMoin.i18n import _, L_, N_
 from MoinMoin.util.forms import FileStorage
 
+COLS = 60
+ROWS = 10
+
 
 class Enum(BaseEnum):
     """
@@ -158,6 +161,9 @@
 Names = MyJoinedString.of(String).with_properties(widget=WIDGET_TEXT).using(
     label=L_('Names'), optional=True, separator=', ', separator_regex=re.compile(r'\s*,\s*'))
 
+Subscriptions = MyJoinedString.of(String).with_properties(widget=WIDGET_MULTILINE_TEXT, rows=ROWS, cols=COLS).using(
+    label=L_('Subscriptions'), optional=True, separator='\n', separator_regex=re.compile(r'[\r\n]+'))
+
 Search = Text.using(default=u'', optional=True).with_properties(widget=WIDGET_SEARCH, placeholder=L_("Search Query"))
 
 _Integer = Integer.validated_by(Converted())
--- a/MoinMoin/templates/usersettings_ajax.html	Wed Aug 21 17:00:14 2013 +0300
+++ b/MoinMoin/templates/usersettings_ajax.html	Mon Aug 26 19:24:07 2013 +0300
@@ -12,4 +12,6 @@
     {{ user_forms.navigation(form) }}
 {% elif part == 'options' %}
     {{ user_forms.options(form) }}
+{% elif part == 'subscriptions' %}
+    {{ user_forms.subscriptions(form) }}
 {% endif %}
--- a/MoinMoin/templates/usersettings_forms.html	Wed Aug 21 17:00:14 2013 +0300
+++ b/MoinMoin/templates/usersettings_forms.html	Mon Aug 26 19:24:07 2013 +0300
@@ -83,6 +83,17 @@
 {{ gen.form.close() }}
 {% endmacro %}
 
+{% macro subscriptions(form) %}
+{{ gen.form.open(form, method="post", action=url_for('frontend.usersettings')) }}
+{{ forms.render_errors(form) }}
+<dl>
+    {{ forms.render(form['subscriptions']) }}
+</dl>
+{{ forms.render_hidden('part', 'subscriptions') }}
+{{ forms.render_submit(form) }}
+{{ gen.form.close() }}
+{% endmacro %}
+
 {# javascript functions within common.js are dependent upon the structure, classes and ids defined here #}
 {% macro all_usersettings_forms(form_objs) %}
 <div id="moin-usersettings">
@@ -110,5 +121,9 @@
         <h2 class="moin-settings-head"><a href="#options">{{ _("Options") }}</a></h2>
         {{ options(form_objs.options) }}
     </div>
+    <div id="subscriptions" class="moin-tab-body moin-form">
+        <h2 class="moin-settings-head"><a href="#subscriptions">{{ _("Subscriptions") }}</a></h2>
+        {{ subscriptions(form_objs.subscriptions) }}
+    </div>
 </div>
 {% endmacro %}