diff --git a/src/postorius/forms.py b/src/postorius/forms.py index 8da59c8..57c72fd 100644 --- a/src/postorius/forms.py +++ b/src/postorius/forms.py @@ -413,8 +413,10 @@ 'recommended (and in fact, your ability to disable these headers ' 'may eventually go away).')) allow_list_posts = forms.TypedChoiceField( + coerce=lambda x: x == 'True', choices=((True, _('Yes')), (False, _('No'))), widget=forms.RadioSelect, + required=False, label=_("Include the list post header"), help_text=_( "This can be set to no for announce lists that do not wish to " @@ -428,7 +430,7 @@ 'It is only used if the reply-to is set to use an explicitly set ' 'header')) first_strip_reply_to = forms.TypedChoiceField( - coerce=lambda x: x == 'False', + coerce=lambda x: x == 'True', choices=((True, _('Yes')), (False, _('No'))), widget=forms.RadioSelect, required=False, diff --git a/src/postorius/tests/fixtures/vcr_cassettes/ListSettingsTest.test_bug_117.yaml b/src/postorius/tests/fixtures/vcr_cassettes/ListSettingsTest.test_bug_117.yaml new file mode 100644 index 0000000..a079dc3 --- /dev/null +++ b/src/postorius/tests/fixtures/vcr_cassettes/ListSettingsTest.test_bug_117.yaml @@ -0,0 +1,426 @@ +interactions: +- request: + body: mail_host=example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/domains + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + content-type: [application/json; charset=UTF-8] + location: ['http://localhost:9001/3.0/domains/example.com'] + status: {code: 201, message: Created} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/domains/example.com + response: + body: {string: !!python/unicode '{"base_url": "http://example.com", "description": + null, "http_etag": "\"e736411818ff1815ca83575e0958c38c5188f0a4\"", "mail_host": + "example.com", "self_link": "http://localhost:9001/3.0/domains/example.com", + "url_host": "example.com"}'} + headers: + content-length: ['233'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: fqdn_listname=foo%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/lists + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + content-type: [application/json; charset=UTF-8] + location: ['http://localhost:9001/3.0/lists/foo.example.com'] + status: {code: 201, message: Created} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/foo.example.com + response: + body: {string: !!python/unicode '{"display_name": "Foo", "fqdn_listname": "foo@example.com", + "http_etag": "\"698a819bbb6b902096a8c5543cc7fac2328960d5\"", "list_id": "foo.example.com", + "list_name": "foo", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/foo.example.com", "volume": 1}'} + headers: + content-length: ['294'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: list_id=foo.example.com&role=owner&subscriber=owner%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + content-type: [application/json; charset=UTF-8] + location: ['http://localhost:9001/3.0/members/1'] + status: {code: 201, message: Created} +- request: + body: list_id=foo.example.com&role=moderator&subscriber=moderator%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + content-type: [application/json; charset=UTF-8] + location: ['http://localhost:9001/3.0/members/2'] + status: {code: 201, message: Created} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/foo@example.com/config + response: + body: {string: !!python/unicode '{"acceptable_aliases": [], "admin_immed_notify": + true, "admin_notify_mchanges": false, "administrivia": true, "advertised": + true, "allow_list_posts": true, "anonymous_list": false, "archive_policy": + "public", "autorespond_owner": "none", "autorespond_postings": "none", "autorespond_requests": + "none", "autoresponse_grace_period": "90d", "autoresponse_owner_text": "", + "autoresponse_postings_text": "", "autoresponse_request_text": "", "bounces_address": + "foo-bounces@example.com", "collapse_alternatives": true, "convert_html_to_plaintext": + false, "created_at": "2005-08-01T07:49:23", "default_member_action": "defer", + "default_nonmember_action": "hold", "description": "", "digest_last_sent_at": + null, "digest_send_periodic": true, "digest_size_threshold": 30.0, "digest_volume_frequency": + "monthly", "digests_enabled": true, "display_name": "Foo", "filter_content": + false, "first_strip_reply_to": false, "fqdn_listname": "foo@example.com", + "goodbye_message_uri": "", "http_etag": "\"97436ece60591c8bf4b4d589f6b8028a5a2964a3\"", + "include_rfc2369_headers": true, "join_address": "foo-join@example.com", "last_post_at": + null, "leave_address": "foo-leave@example.com", "list_name": "foo", "mail_host": + "example.com", "next_digest_number": 1, "no_reply_address": "noreply@example.com", + "owner_address": "foo-owner@example.com", "post_id": 1, "posting_address": + "foo@example.com", "posting_pipeline": "default-posting-pipeline", "reply_goes_to_list": + "no_munging", "reply_to_address": "", "request_address": "foo-request@example.com", + "scheme": "http", "send_welcome_message": true, "subject_prefix": "[Foo] ", + "subscription_policy": "confirm", "volume": 1, "web_host": "example.com", + "welcome_message_uri": "mailman:///welcome.txt"}'} + headers: + content-length: ['1730'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/users/su@example.com + response: + body: {string: !!python/unicode 404 Not Found} + headers: + content-length: ['13'] + content-type: [application/json; charset=UTF-8] + status: {code: 404, message: Not Found} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/foo.example.com + response: + body: {string: !!python/unicode '{"display_name": "Foo", "fqdn_listname": "foo@example.com", + "http_etag": "\"698a819bbb6b902096a8c5543cc7fac2328960d5\"", "list_id": "foo.example.com", + "list_name": "foo", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/foo.example.com", "volume": 1}'} + headers: + content-length: ['294'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/foo@example.com/config + response: + body: {string: !!python/unicode '{"acceptable_aliases": [], "admin_immed_notify": + true, "admin_notify_mchanges": false, "administrivia": true, "advertised": + true, "allow_list_posts": true, "anonymous_list": false, "archive_policy": + "public", "autorespond_owner": "none", "autorespond_postings": "none", "autorespond_requests": + "none", "autoresponse_grace_period": "90d", "autoresponse_owner_text": "", + "autoresponse_postings_text": "", "autoresponse_request_text": "", "bounces_address": + "foo-bounces@example.com", "collapse_alternatives": true, "convert_html_to_plaintext": + false, "created_at": "2005-08-01T07:49:23", "default_member_action": "defer", + "default_nonmember_action": "hold", "description": "", "digest_last_sent_at": + null, "digest_send_periodic": true, "digest_size_threshold": 30.0, "digest_volume_frequency": + "monthly", "digests_enabled": true, "display_name": "Foo", "filter_content": + false, "first_strip_reply_to": false, "fqdn_listname": "foo@example.com", + "goodbye_message_uri": "", "http_etag": "\"97436ece60591c8bf4b4d589f6b8028a5a2964a3\"", + "include_rfc2369_headers": true, "join_address": "foo-join@example.com", "last_post_at": + null, "leave_address": "foo-leave@example.com", "list_name": "foo", "mail_host": + "example.com", "next_digest_number": 1, "no_reply_address": "noreply@example.com", + "owner_address": "foo-owner@example.com", "post_id": 1, "posting_address": + "foo@example.com", "posting_pipeline": "default-posting-pipeline", "reply_goes_to_list": + "no_munging", "reply_to_address": "", "request_address": "foo-request@example.com", + "scheme": "http", "send_welcome_message": true, "subject_prefix": "[Foo] ", + "subscription_policy": "confirm", "volume": 1, "web_host": "example.com", + "welcome_message_uri": "mailman:///welcome.txt"}'} + headers: + content-length: ['1730'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/users/su@example.com + response: + body: {string: !!python/unicode 404 Not Found} + headers: + content-length: ['13'] + content-type: [application/json; charset=UTF-8] + status: {code: 404, message: Not Found} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/foo.example.com + response: + body: {string: !!python/unicode '{"display_name": "Foo", "fqdn_listname": "foo@example.com", + "http_etag": "\"698a819bbb6b902096a8c5543cc7fac2328960d5\"", "list_id": "foo.example.com", + "list_name": "foo", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/foo.example.com", "volume": 1}'} + headers: + content-length: ['294'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/foo@example.com/config + response: + body: {string: !!python/unicode '{"acceptable_aliases": [], "admin_immed_notify": + true, "admin_notify_mchanges": false, "administrivia": true, "advertised": + true, "allow_list_posts": true, "anonymous_list": false, "archive_policy": + "public", "autorespond_owner": "none", "autorespond_postings": "none", "autorespond_requests": + "none", "autoresponse_grace_period": "90d", "autoresponse_owner_text": "", + "autoresponse_postings_text": "", "autoresponse_request_text": "", "bounces_address": + "foo-bounces@example.com", "collapse_alternatives": true, "convert_html_to_plaintext": + false, "created_at": "2005-08-01T07:49:23", "default_member_action": "defer", + "default_nonmember_action": "hold", "description": "", "digest_last_sent_at": + null, "digest_send_periodic": true, "digest_size_threshold": 30.0, "digest_volume_frequency": + "monthly", "digests_enabled": true, "display_name": "Foo", "filter_content": + false, "first_strip_reply_to": false, "fqdn_listname": "foo@example.com", + "goodbye_message_uri": "", "http_etag": "\"97436ece60591c8bf4b4d589f6b8028a5a2964a3\"", + "include_rfc2369_headers": true, "join_address": "foo-join@example.com", "last_post_at": + null, "leave_address": "foo-leave@example.com", "list_name": "foo", "mail_host": + "example.com", "next_digest_number": 1, "no_reply_address": "noreply@example.com", + "owner_address": "foo-owner@example.com", "post_id": 1, "posting_address": + "foo@example.com", "posting_pipeline": "default-posting-pipeline", "reply_goes_to_list": + "no_munging", "reply_to_address": "", "request_address": "foo-request@example.com", + "scheme": "http", "send_welcome_message": true, "subject_prefix": "[Foo] ", + "subscription_policy": "confirm", "volume": 1, "web_host": "example.com", + "welcome_message_uri": "mailman:///welcome.txt"}'} + headers: + content-length: ['1730'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: first_strip_reply_to=True + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode PATCH + uri: http://localhost:9001/3.0/lists/foo@example.com/config + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/users/su@example.com + response: + body: {string: !!python/unicode 404 Not Found} + headers: + content-length: ['13'] + content-type: [application/json; charset=UTF-8] + status: {code: 404, message: Not Found} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/foo.example.com + response: + body: {string: !!python/unicode '{"display_name": "Foo", "fqdn_listname": "foo@example.com", + "http_etag": "\"698a819bbb6b902096a8c5543cc7fac2328960d5\"", "list_id": "foo.example.com", + "list_name": "foo", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/foo.example.com", "volume": 1}'} + headers: + content-length: ['294'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/foo@example.com/config + response: + body: {string: !!python/unicode '{"acceptable_aliases": [], "admin_immed_notify": + true, "admin_notify_mchanges": false, "administrivia": true, "advertised": + true, "allow_list_posts": true, "anonymous_list": false, "archive_policy": + "public", "autorespond_owner": "none", "autorespond_postings": "none", "autorespond_requests": + "none", "autoresponse_grace_period": "90d", "autoresponse_owner_text": "", + "autoresponse_postings_text": "", "autoresponse_request_text": "", "bounces_address": + "foo-bounces@example.com", "collapse_alternatives": true, "convert_html_to_plaintext": + false, "created_at": "2005-08-01T07:49:23", "default_member_action": "defer", + "default_nonmember_action": "hold", "description": "", "digest_last_sent_at": + null, "digest_send_periodic": true, "digest_size_threshold": 30.0, "digest_volume_frequency": + "monthly", "digests_enabled": true, "display_name": "Foo", "filter_content": + false, "first_strip_reply_to": true, "fqdn_listname": "foo@example.com", "goodbye_message_uri": + "", "http_etag": "\"511d5cabc350f8d131ed21d9ad9a7525ac63a0c4\"", "include_rfc2369_headers": + true, "join_address": "foo-join@example.com", "last_post_at": null, "leave_address": + "foo-leave@example.com", "list_name": "foo", "mail_host": "example.com", "next_digest_number": + 1, "no_reply_address": "noreply@example.com", "owner_address": "foo-owner@example.com", + "post_id": 1, "posting_address": "foo@example.com", "posting_pipeline": "default-posting-pipeline", + "reply_goes_to_list": "no_munging", "reply_to_address": "", "request_address": + "foo-request@example.com", "scheme": "http", "send_welcome_message": true, + "subject_prefix": "[Foo] ", "subscription_policy": "confirm", "volume": 1, + "web_host": "example.com", "welcome_message_uri": "mailman:///welcome.txt"}'} + headers: + content-length: ['1729'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/foo.example.com + response: + body: {string: !!python/unicode '{"display_name": "Foo", "fqdn_listname": "foo@example.com", + "http_etag": "\"698a819bbb6b902096a8c5543cc7fac2328960d5\"", "list_id": "foo.example.com", + "list_name": "foo", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/foo.example.com", "volume": 1}'} + headers: + content-length: ['294'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/foo@example.com/config + response: + body: {string: !!python/unicode '{"acceptable_aliases": [], "admin_immed_notify": + true, "admin_notify_mchanges": false, "administrivia": true, "advertised": + true, "allow_list_posts": true, "anonymous_list": false, "archive_policy": + "public", "autorespond_owner": "none", "autorespond_postings": "none", "autorespond_requests": + "none", "autoresponse_grace_period": "90d", "autoresponse_owner_text": "", + "autoresponse_postings_text": "", "autoresponse_request_text": "", "bounces_address": + "foo-bounces@example.com", "collapse_alternatives": true, "convert_html_to_plaintext": + false, "created_at": "2005-08-01T07:49:23", "default_member_action": "defer", + "default_nonmember_action": "hold", "description": "", "digest_last_sent_at": + null, "digest_send_periodic": true, "digest_size_threshold": 30.0, "digest_volume_frequency": + "monthly", "digests_enabled": true, "display_name": "Foo", "filter_content": + false, "first_strip_reply_to": true, "fqdn_listname": "foo@example.com", "goodbye_message_uri": + "", "http_etag": "\"511d5cabc350f8d131ed21d9ad9a7525ac63a0c4\"", "include_rfc2369_headers": + true, "join_address": "foo-join@example.com", "last_post_at": null, "leave_address": + "foo-leave@example.com", "list_name": "foo", "mail_host": "example.com", "next_digest_number": + 1, "no_reply_address": "noreply@example.com", "owner_address": "foo-owner@example.com", + "post_id": 1, "posting_address": "foo@example.com", "posting_pipeline": "default-posting-pipeline", + "reply_goes_to_list": "no_munging", "reply_to_address": "", "request_address": + "foo-request@example.com", "scheme": "http", "send_welcome_message": true, + "subject_prefix": "[Foo] ", "subscription_policy": "confirm", "volume": 1, + "web_host": "example.com", "welcome_message_uri": "mailman:///welcome.txt"}'} + headers: + content-length: ['1729'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/domains + response: + body: {string: !!python/unicode '{"entries": [{"base_url": "http://example.com", + "description": null, "http_etag": "\"e736411818ff1815ca83575e0958c38c5188f0a4\"", + "mail_host": "example.com", "self_link": "http://localhost:9001/3.0/domains/example.com", + "url_host": "example.com"}], "http_etag": "\"c385b155f8da284bf78dbe075e20f58a30c893ab\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['338'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode DELETE + uri: http://localhost:9001/3.0/domains/example.com + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/users + response: + body: {string: !!python/unicode '{"entries": [{"created_on": "2005-08-01T07:49:23", + "http_etag": "\"eb591d9720aa0ac944b49315b6af1c950410b54c\"", "is_server_owner": + false, "self_link": "http://localhost:9001/3.0/users/1", "user_id": 1}, {"created_on": + "2005-08-01T07:49:23", "http_etag": "\"b36f8ca1d91d583901c768dc116815282d469c66\"", + "is_server_owner": false, "self_link": "http://localhost:9001/3.0/users/2", + "user_id": 2}], "http_etag": "\"02a1b3f934bd7d185e0442a63a169c0f3f356f60\"", + "start": 0, "total_size": 2}'} + headers: + content-length: ['483'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode DELETE + uri: http://localhost:9001/3.0/users/1 + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode DELETE + uri: http://localhost:9001/3.0/users/2 + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +version: 1 diff --git a/src/postorius/tests/mailman_api_tests/test_list_settings.py b/src/postorius/tests/mailman_api_tests/test_list_settings.py index 04ff952..4f96c72 100644 --- a/src/postorius/tests/mailman_api_tests/test_list_settings.py +++ b/src/postorius/tests/mailman_api_tests/test_list_settings.py @@ -119,3 +119,20 @@ self.assertEqual(dict(m_list.archivers), {'mhonarc': False, 'prototype': True, 'mail-archive': False}) + + def test_bug_117(self): + self.assertEqual(self.foo_list.settings['first_strip_reply_to'], False) + self.client.login(username='testsu', password='testpass') + url = reverse( + 'list_settings', args=('foo.example.com', 'alter_messages')) + response = self.client.get(url) + self.assertEqual(response.status_code, 200) + form = response.context["form"] + self.assertEqual( + form.initial['first_strip_reply_to'], False) + response = self.client.post(url, {'first_strip_reply_to': 'True'}) + self.assertRedirects(response, url) + self.assertHasSuccessMessage(response) + # Get a new list object to avoid caching + m_list = List.objects.get(fqdn_listname='foo.example.com') + self.assertEqual(m_list.settings['first_strip_reply_to'], True)