incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [2/2] git commit: [#5563] ticket:340 refactored subscriptions page
Date Wed, 15 May 2013 15:20:50 GMT
[#5563]  ticket:340 refactored subscriptions page


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/e20e8785
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/e20e8785
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/e20e8785

Branch: refs/heads/master
Commit: e20e8785008fdf5345d6d34718e52f9ba9b8833c
Parents: 97ddc15
Author: Yuriy Arhipov <yuriyarhipovua@yandex.ru>
Authored: Thu May 9 00:27:11 2013 +0400
Committer: Yuriy Arhipov <yuriyarhipovua@yandex.ru>
Committed: Wed May 15 09:39:27 2013 +0400

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py           |    5 ++++-
 Allura/allura/lib/widgets/subscriptions.py  |    8 ++++++++
 Allura/allura/templates/user_subs.html      |   19 +++----------------
 Allura/allura/tests/functional/test_auth.py |   11 +++++++++++
 4 files changed, 26 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e20e8785/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 4dc83e7..1c5891f 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -744,7 +744,7 @@ class SubscriptionsController(BaseController):
     @expose()
     @require_post()
     @validate(F.subscription_form, error_handler=index)
-    def update_subscriptions(self, subscriptions=None, **kw):
+    def update_subscriptions(self, subscriptions=None, email_format=None, **kw):
         for s in subscriptions:
             if s['subscribed']:
                 if s['tool_id'] and s['project_id']:
@@ -754,6 +754,9 @@ class SubscriptionsController(BaseController):
             else:
                 if s['subscription_id'] is not None:
                     s['subscription_id'].delete()
+        if email_format:
+            c.user.set_pref('email_format', email_format)
+
         redirect(request.referer)
 
 class OAuthController(BaseController):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e20e8785/Allura/allura/lib/widgets/subscriptions.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/subscriptions.py b/Allura/allura/lib/widgets/subscriptions.py
index 4439de7..a0a1bc3 100644
--- a/Allura/allura/lib/widgets/subscriptions.py
+++ b/Allura/allura/lib/widgets/subscriptions.py
@@ -50,6 +50,14 @@ class SubscriptionForm(ew.SimpleForm):
         submit_text='Save')
     class fields(ew_core.NameList):
         subscriptions=_SubscriptionTable()
+        email_format = ew.SingleSelectField(
+                    name='email_format',
+                    label='Email Format',
+                    options=[
+                        ew.Option(py_value='plain', label='Plain Text'),
+                        ew.Option(py_value='html', label='HTML'),
+                        ew.Option(py_value='both', label='Combined')])
+
 
 class SubscribeForm(ew.SimpleForm):
     template='jinja:allura:templates/widgets/subscribe.html'

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e20e8785/Allura/allura/templates/user_subs.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/user_subs.html b/Allura/allura/templates/user_subs.html
index e94bbd7..19b9a6a 100644
--- a/Allura/allura/templates/user_subs.html
+++ b/Allura/allura/templates/user_subs.html
@@ -49,24 +49,11 @@
   <h2>Subscriptions</h2>
   {% if subscriptions %}
     <p><em>Mark tools that you want to subscribe to. Unmark tools that you want
to unsubscribe from. Press 'Save' button.</em></p>
-    {{c.form.display(action='update_subscriptions', value=dict(subscriptions=subscriptions))}}
+        <div class="grid-24">
+        {{c.form.display(action='update_subscriptions', value=dict(subscriptions=subscriptions,
email_format=c.user.preferences.email_format))}}
+        </div>
   {% else%}
     <p>No subscriptions.</p>
   {% endif %}
-  <hr/>
-  <div style="clear:both">&nbsp;</div>
-  <form action="update" method="post">
-        <label class="grid-4">Email Format</label>
-        <div class="grid-18">
-          <select name="preferences.email_format">
-            <option value="plain" {{'selected' if c.user.preferences.email_format == 'plain'
else ''}}>Plain Text</option>
-            <option value="html" {{'selected' if c.user.preferences.email_format == 'html'
else ''}}>HTML</option>
-            <option value="both" {{'selected' if c.user.preferences.email_format == 'both'
else ''}}>Combined</option>
-          </select>
-        </div>
 
-    <div class="grid-18">
-    {{lib.submit_button('Save Changes')}}
-    </div>
-  </form>
 {% endblock %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e20e8785/Allura/allura/tests/functional/test_auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_auth.py b/Allura/allura/tests/functional/test_auth.py
index ccdf2e2..247e8b8 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -163,6 +163,17 @@ class TestAuth(TestController):
         s = M.Mailbox.query.get(_id=s_id)
         assert not s, "User still has subscription with Mailbox._id %s" % s_id
 
+    def test_format_email(self):
+        self.app.post('/auth/subscriptions/update_subscriptions', params={'email_format':
'html', 'subscriptions': ''})
+        r = self.app.get('/auth/subscriptions/')
+        assert '<option selected value="html">HTML</option>' in r
+        self.app.post('/auth/subscriptions/update_subscriptions', params={'email_format':
'plain', 'subscriptions': ''})
+        r = self.app.get('/auth/subscriptions/')
+        assert '<option selected value="plain">Plain Text</option>' in r
+        self.app.post('/auth/subscriptions/update_subscriptions', params={'email_format':
'both', 'subscriptions': ''})
+        r = self.app.get('/auth/subscriptions/')
+        assert '<option selected value="both">Combined</option>' in r
+
     def test_api_key(self):
          r = self.app.get('/auth/preferences/')
          assert 'No API token generated' in r


Mime
View raw message