This is an automated email from the ASF dual-hosted git repository. gcruz pushed a commit to branch subscribe-checkbox in repository https://gitbox.apache.org/repos/asf/allura.git
commit 40fcda3ff7db9e219335e62eb06693956acd5b46 Author: Guillermo Cruz <[email protected]> AuthorDate: Mon Nov 22 08:33:46 2021 -0700 removed default checked attribute from checkboxes from wiki and topic forms unless they are replies and added a few tests --- Allura/allura/lib/widgets/discuss.py | 1 + Allura/allura/templates/widgets/edit_post.html | 2 +- .../allura/templates/widgets/new_topic_post.html | 2 +- Allura/allura/templates/widgets/post_widget.html | 1 + Allura/allura/tests/functional/test_discuss.py | 42 ++++++++++++++++++++++ .../allura/tests/functional/test_user_profile.py | 16 ++++++++- ForgeWiki/forgewiki/templates/wiki/page_edit.html | 2 +- 7 files changed, 62 insertions(+), 4 deletions(-) diff --git a/Allura/allura/lib/widgets/discuss.py b/Allura/allura/lib/widgets/discuss.py index 9338fbb..d66f602 100644 --- a/Allura/allura/lib/widgets/discuss.py +++ b/Allura/allura/lib/widgets/discuss.py @@ -149,6 +149,7 @@ class EditPost(ff.ForgeForm): antispam = True defaults = dict( ff.ForgeForm.defaults, + subscribe_checked=False, show_subject=False, value=None, att_name='file_info') diff --git a/Allura/allura/templates/widgets/edit_post.html b/Allura/allura/templates/widgets/edit_post.html index 6f0de46..94ff166 100644 --- a/Allura/allura/templates/widgets/edit_post.html +++ b/Allura/allura/templates/widgets/edit_post.html @@ -34,7 +34,7 @@ <input type="submit" value="{{submit_text}}" /> {% if primary_artifact and c.user and c.user != c.user.anonymous() and not primary_artifact.subscribed() %} <label class="subscribe"> - <input type="checkbox" checked name="subscribe" class="subscribe-checkbox">Subscribe to this {{ primary_artifact.type_name }} + <input type="checkbox" {% if primary_artifact.type_name not in ['wiki page','topic'] or subscribe_checked %}checked{% endif %} name="subscribe" class="subscribe-checkbox">Subscribe to this {{ primary_artifact.type_name }} </label> {% endif %} <a href="#" class="ui-button btn link cancel_edit_post">Cancel</a> diff --git a/Allura/allura/templates/widgets/new_topic_post.html b/Allura/allura/templates/widgets/new_topic_post.html index e62249e..e43f40f 100644 --- a/Allura/allura/templates/widgets/new_topic_post.html +++ b/Allura/allura/templates/widgets/new_topic_post.html @@ -52,7 +52,7 @@ {% if c.user and c.user != c.user.anonymous() and not (subscribed or subscribed_to_tool) %} {# subscribed is per-forum and won't change if they change the forum dropdown value, but better than nothing? :( #} <label class="subscribe"> - <input type="checkbox" checked name="subscribe" class="subscribe-checkbox">Subscribe to this topic + <input type="checkbox" name="subscribe" class="subscribe-checkbox">Subscribe to this topic </label> {% endif %} <a href=".." class="btn link cancel_form">Cancel</a> diff --git a/Allura/allura/templates/widgets/post_widget.html b/Allura/allura/templates/widgets/post_widget.html index f8f65f3..b0dd0e4 100644 --- a/Allura/allura/templates/widgets/post_widget.html +++ b/Allura/allura/templates/widgets/post_widget.html @@ -174,6 +174,7 @@ <div class="grid-14 bubble" style="width: {{indent <= 40 and 625-indent*10 or 225}}px"> {{widgets.edit_post.display( submit_text='Post Reply', + subscribe_checked=True, action=value.url()+'reply', value=dict( text='', diff --git a/Allura/allura/tests/functional/test_discuss.py b/Allura/allura/tests/functional/test_discuss.py index 4369482..26ff840 100644 --- a/Allura/allura/tests/functional/test_discuss.py +++ b/Allura/allura/tests/functional/test_discuss.py @@ -29,6 +29,7 @@ from allura.lib import helpers as h from tg import config from io import open from six.moves import range +from allura.tests import decorators as td class TestDiscussBase(TestController): @@ -46,6 +47,47 @@ class TestDiscussBase(TestController): return thread_link.split('/')[-2] + +class TestTopic(TestController): + + @td.with_user_project('test-user') + @td.with_discussion + def test_no_subscribe_topic(self): + topic = self.app.get('/p/test/discussion/create_topic/general/') + subscribe_checkbox = topic.html.find('input', {'type': 'checkbox'}) + assert_true(subscribe_checkbox, topic.html) + is_subscribed = subscribe_checkbox.get('checked') + assert_equal(is_subscribed, None) + + @td.with_user_project('test-admin') + @td.with_discussion + def test_subscribe_topic(self): + t = self.app.get('/discussion/') + ul = t.html.findAll('ul', {'class': 'sidebarmenu'})[1] + li = ul.findAll('li') + topic = self.app.get(li[0].find('a').get('href')) + form = topic.html.find('form', {'id': 'create_new_topic'}) + action = form.get('action') + inputs = form.findAll('input') + params = dict() + for field in inputs: + if field.has_attr('name'): + params[field['name']] = field.get('value') or '' + params[form.find('textarea')['name']] = 'This is a *test thread*' + params[form.find('select')['name']] = 'general' + params[form.find('input', {'style': 'width: 90%'})['name']] = 'Test Thread' + r = self.app.post(action, params=params) + topic_posted = r.follow() + assert 'Message posted' in topic_posted + assert 'This is a *test thread*' in topic_posted + edit_reply_form = topic_posted.html.find('form', {'id': 'edit_eply'}) + reply_is_subscribed = edit_reply_form.find('input', {'class': 'subscribe-checkbox'}) + assert_equal(reply_is_subscribed.get('checked'),'') + edit_post_form = topic_posted.html.find('form', {'id': 'edit_post'}) + edit_no_subscribed = edit_post_form.find('input', {'class': 'subscribe-checkbox'}) + assert_equal(edit_no_subscribed.get('checked'),None) + + class TestDiscuss(TestDiscussBase): def _is_subscribed(self, user, thread): diff --git a/Allura/allura/tests/functional/test_user_profile.py b/Allura/allura/tests/functional/test_user_profile.py index ecaa6f5..26cbe2e 100644 --- a/Allura/allura/tests/functional/test_user_profile.py +++ b/Allura/allura/tests/functional/test_user_profile.py @@ -19,7 +19,12 @@ from __future__ import unicode_literals from __future__ import absolute_import import mock import tg -from alluratest.tools import assert_equal, assert_in, assert_not_in +from alluratest.tools import ( + assert_equal, + assert_in, + assert_not_in, + assert_true +) from alluratest.controller import TestRestApiBase from allura.model import Project, User @@ -270,6 +275,15 @@ class TestUserProfile(TestController): r = self.app.get('/u/test-admin/profile/') assert 'content="noindex, follow"' not in r.text + @td.with_user_project('test-user') + @td.with_wiki + def test_no_subscribe(self): + home = self.app.get('/u/test-user/wiki/Home/') + subscribe_checkbox = home.html.find('input', {'type': 'checkbox'}) + assert_true(subscribe_checkbox, home.html) + is_subscribed = subscribe_checkbox.get('checked') + assert_equal(is_subscribed, None) + diff --git a/ForgeWiki/forgewiki/templates/wiki/page_edit.html b/ForgeWiki/forgewiki/templates/wiki/page_edit.html index 6d43a51..997a784 100644 --- a/ForgeWiki/forgewiki/templates/wiki/page_edit.html +++ b/ForgeWiki/forgewiki/templates/wiki/page_edit.html @@ -72,7 +72,7 @@ <input type="reset" value="Cancel"> {% if c.user and c.user != c.user.anonymous() and not subscribed_to_tool %} <label class="subscribe"> - <input type="checkbox" checked name="subscribe" class="subscribe-checkbox">Subscribe to this wiki page + <input type="checkbox" name="subscribe" class="subscribe-checkbox">Subscribe to this wiki page </label> {% endif %} </div>
