diff --git a/src/postorius/forms.py b/src/postorius/forms.py index 7c6fb45..58ebb5d 100644 --- a/src/postorius/forms.py +++ b/src/postorius/forms.py @@ -800,10 +800,11 @@ label=_('Moderation'), error_messages={ 'required': _("Please choose a moderation action.")}, - required=True, - choices=ACTION_CHOICES, + required=False, + choices=[(None, _('List default'))] + list(ACTION_CHOICES), help_text=_( 'Default action to take when this member posts to the list. ' + 'List default -- follow the list\'s default member action. ' 'Hold -- This holds the message for approval by the list ' 'moderators. ' 'Reject -- this automatically rejects the message by sending a ' diff --git a/src/postorius/tests/fixtures/vcr_cassettes/ListMembersOptionsTest.test_moderation_action.yaml b/src/postorius/tests/fixtures/vcr_cassettes/ListMembersOptionsTest.test_moderation_action.yaml new file mode 100644 index 0000000..f542bb8 --- /dev/null +++ b/src/postorius/tests/fixtures/vcr_cassettes/ListMembersOptionsTest.test_moderation_action.yaml @@ -0,0 +1,606 @@ +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/25'] + 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/26'] + status: {code: 201, message: Created} +- request: + body: email=test%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/users + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + content-type: [application/json; charset=UTF-8] + location: ['http://localhost:9001/3.0/users/27'] + status: {code: 201, message: Created} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/users/27 + response: + body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag": + "\"d5c9e2ff74032042aba83dcf2b1cc2f0cd9495a8\"", "is_server_owner": false, + "password": "$6$rounds=702318$RY1JZNyy2pj3R6UB$WlqhPTL2MgRq.wPLjTaigkJ9nn6i40m1mLzpXts/G98BcYt1zt6oECNIxlXT5Ihyhq4AX/EdC5AbSh3yHoNlN0", + "self_link": "http://localhost:9001/3.0/users/27", "user_id": 27}'} + headers: + content-length: ['326'] + 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/27/addresses + response: + body: {string: !!python/unicode '{"entries": [{"email": "test@example.com", "http_etag": + "\"ad8ac76a93e51a3d36c47c3565f996c1629b6caa\"", "original_email": "test@example.com", + "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/test@example.com", + "user": "http://localhost:9001/3.0/users/27"}], "http_etag": "\"f2bf8b02c220c810aca7bf6ce4627feb3fac56b6\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['388'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/addresses/test@example.com/verify + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +- request: + body: display_name=None&list_id=foo.example.com&pre_approved=True&pre_confirmed=True&pre_verified=True&subscriber=test%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/27'] + 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/member/test@example.com + response: + body: {string: !!python/unicode '{"address": "http://localhost:9001/3.0/addresses/test@example.com", + "delivery_mode": "regular", "email": "test@example.com", "http_etag": "\"e2c451765e1e4ac82414bfa7ea6153b6a84a851c\"", + "list_id": "foo.example.com", "member_id": 27, "role": "member", "self_link": + "http://localhost:9001/3.0/members/27", "user": "http://localhost:9001/3.0/users/27"}'} + headers: + content-length: ['349'] + 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/member/test@example.com + response: + body: {string: !!python/unicode '{"address": "http://localhost:9001/3.0/addresses/test@example.com", + "delivery_mode": "regular", "email": "test@example.com", "http_etag": "\"e2c451765e1e4ac82414bfa7ea6153b6a84a851c\"", + "list_id": "foo.example.com", "member_id": 27, "role": "member", "self_link": + "http://localhost:9001/3.0/members/27", "user": "http://localhost:9001/3.0/users/27"}'} + headers: + content-length: ['349'] + 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": "\"98cc998d4a30293ec17da639bce10617912a6e1e\"", "list_id": "foo.example.com", + "list_name": "foo", "mail_host": "example.com", "member_count": 1, "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 + response: + body: {string: !!python/unicode '{"display_name": "Foo", "fqdn_listname": "foo@example.com", + "http_etag": "\"98cc998d4a30293ec17da639bce10617912a6e1e\"", "list_id": "foo.example.com", + "list_name": "foo", "mail_host": "example.com", "member_count": 1, "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/member/test@example.com + response: + body: {string: !!python/unicode '{"address": "http://localhost:9001/3.0/addresses/test@example.com", + "delivery_mode": "regular", "email": "test@example.com", "http_etag": "\"e2c451765e1e4ac82414bfa7ea6153b6a84a851c\"", + "list_id": "foo.example.com", "member_id": 27, "role": "member", "self_link": + "http://localhost:9001/3.0/members/27", "user": "http://localhost:9001/3.0/users/27"}'} + headers: + content-length: ['349'] + 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/members/27/preferences + response: + body: {string: !!python/unicode '{"http_etag": "\"35211d8d79343dd8ab3a8f26e7aa89a465f2feea\"", + "self_link": "http://localhost:9001/3.0/members/27/preferences"}'} + headers: + content-length: ['126'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: moderation_action=hold + 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/members/27 + 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": "\"98cc998d4a30293ec17da639bce10617912a6e1e\"", "list_id": "foo.example.com", + "list_name": "foo", "mail_host": "example.com", "member_count": 1, "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 + response: + body: {string: !!python/unicode '{"display_name": "Foo", "fqdn_listname": "foo@example.com", + "http_etag": "\"98cc998d4a30293ec17da639bce10617912a6e1e\"", "list_id": "foo.example.com", + "list_name": "foo", "mail_host": "example.com", "member_count": 1, "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/member/test@example.com + response: + body: {string: !!python/unicode '{"address": "http://localhost:9001/3.0/addresses/test@example.com", + "delivery_mode": "regular", "email": "test@example.com", "http_etag": "\"0a01f98f340594bb43e703181e563b15134367d6\"", + "list_id": "foo.example.com", "member_id": 27, "moderation_action": "hold", + "role": "member", "self_link": "http://localhost:9001/3.0/members/27", "user": + "http://localhost:9001/3.0/users/27"}'} + headers: + content-length: ['378'] + 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/members/27/preferences + response: + body: {string: !!python/unicode '{"http_etag": "\"35211d8d79343dd8ab3a8f26e7aa89a465f2feea\"", + "self_link": "http://localhost:9001/3.0/members/27/preferences"}'} + headers: + content-length: ['126'] + 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/member/test@example.com + response: + body: {string: !!python/unicode '{"address": "http://localhost:9001/3.0/addresses/test@example.com", + "delivery_mode": "regular", "email": "test@example.com", "http_etag": "\"0a01f98f340594bb43e703181e563b15134367d6\"", + "list_id": "foo.example.com", "member_id": 27, "moderation_action": "hold", + "role": "member", "self_link": "http://localhost:9001/3.0/members/27", "user": + "http://localhost:9001/3.0/users/27"}'} + headers: + content-length: ['378'] + 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": "\"98cc998d4a30293ec17da639bce10617912a6e1e\"", "list_id": "foo.example.com", + "list_name": "foo", "mail_host": "example.com", "member_count": 1, "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 + response: + body: {string: !!python/unicode '{"display_name": "Foo", "fqdn_listname": "foo@example.com", + "http_etag": "\"98cc998d4a30293ec17da639bce10617912a6e1e\"", "list_id": "foo.example.com", + "list_name": "foo", "mail_host": "example.com", "member_count": 1, "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/member/test@example.com + response: + body: {string: !!python/unicode '{"address": "http://localhost:9001/3.0/addresses/test@example.com", + "delivery_mode": "regular", "email": "test@example.com", "http_etag": "\"0a01f98f340594bb43e703181e563b15134367d6\"", + "list_id": "foo.example.com", "member_id": 27, "moderation_action": "hold", + "role": "member", "self_link": "http://localhost:9001/3.0/members/27", "user": + "http://localhost:9001/3.0/users/27"}'} + headers: + content-length: ['378'] + 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/members/27/preferences + response: + body: {string: !!python/unicode '{"http_etag": "\"35211d8d79343dd8ab3a8f26e7aa89a465f2feea\"", + "self_link": "http://localhost:9001/3.0/members/27/preferences"}'} + headers: + content-length: ['126'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: !!python/unicode moderation_action= + 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/members/27 + 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": "\"98cc998d4a30293ec17da639bce10617912a6e1e\"", "list_id": "foo.example.com", + "list_name": "foo", "mail_host": "example.com", "member_count": 1, "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 + response: + body: {string: !!python/unicode '{"display_name": "Foo", "fqdn_listname": "foo@example.com", + "http_etag": "\"98cc998d4a30293ec17da639bce10617912a6e1e\"", "list_id": "foo.example.com", + "list_name": "foo", "mail_host": "example.com", "member_count": 1, "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/member/test@example.com + response: + body: {string: !!python/unicode '{"address": "http://localhost:9001/3.0/addresses/test@example.com", + "delivery_mode": "regular", "email": "test@example.com", "http_etag": "\"e2c451765e1e4ac82414bfa7ea6153b6a84a851c\"", + "list_id": "foo.example.com", "member_id": 27, "role": "member", "self_link": + "http://localhost:9001/3.0/members/27", "user": "http://localhost:9001/3.0/users/27"}'} + headers: + content-length: ['349'] + 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/members/27/preferences + response: + body: {string: !!python/unicode '{"http_etag": "\"35211d8d79343dd8ab3a8f26e7aa89a465f2feea\"", + "self_link": "http://localhost:9001/3.0/members/27/preferences"}'} + headers: + content-length: ['126'] + 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/member/test@example.com + response: + body: {string: !!python/unicode '{"address": "http://localhost:9001/3.0/addresses/test@example.com", + "delivery_mode": "regular", "email": "test@example.com", "http_etag": "\"e2c451765e1e4ac82414bfa7ea6153b6a84a851c\"", + "list_id": "foo.example.com", "member_id": 27, "role": "member", "self_link": + "http://localhost:9001/3.0/members/27", "user": "http://localhost:9001/3.0/users/27"}'} + headers: + content-length: ['349'] + 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": "\"0c3f6e8712fd05b9da49c42bf9600a5414b7958f\"", "is_server_owner": + false, "self_link": "http://localhost:9001/3.0/users/25", "user_id": 25}, + {"created_on": "2005-08-01T07:49:23", "http_etag": "\"c73be856843a113d5eb32f60ae4315192adb1045\"", + "is_server_owner": false, "self_link": "http://localhost:9001/3.0/users/26", + "user_id": 26}, {"created_on": "2005-08-01T07:49:23", "http_etag": "\"d5c9e2ff74032042aba83dcf2b1cc2f0cd9495a8\"", + "is_server_owner": false, "password": "$6$rounds=702318$RY1JZNyy2pj3R6UB$WlqhPTL2MgRq.wPLjTaigkJ9nn6i40m1mLzpXts/G98BcYt1zt6oECNIxlXT5Ihyhq4AX/EdC5AbSh3yHoNlN0", + "self_link": "http://localhost:9001/3.0/users/27", "user_id": 27}], "http_etag": + "\"8c30e9df1ed2ff50f2a59cf6e94ed532287bffb8\"", "start": 0, "total_size": + 3}'} + headers: + content-length: ['815'] + 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/25 + 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/26 + 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/27 + 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_member_options.py b/src/postorius/tests/mailman_api_tests/test_list_member_options.py index f5c84b6..78bc29d 100644 --- a/src/postorius/tests/mailman_api_tests/test_list_member_options.py +++ b/src/postorius/tests/mailman_api_tests/test_list_member_options.py @@ -52,12 +52,11 @@ pre_confirmed=True, pre_approved=True) self.url = reverse('list_member_options', args=(self.foo_list.list_id, 'test@example.com',)) - self.url = quote(self.url) def test_page_not_accessible_if_not_logged_in(self): response = self.client.get(self.url) self.assertRedirects(response, '{}?next={}'.format( - reverse(settings.LOGIN_URL), self.url)) + reverse(settings.LOGIN_URL), quote(self.url))) def test_page_not_accessible_for_unprivileged_users(self): self.client.login(username='testuser', password='testpass') @@ -86,3 +85,22 @@ MemberModeration) self.assertIsInstance(response.context['preferences_form'], UserPreferences) + + def test_moderation_action(self): + member = self.foo_list.get_member('test@example.com') + self.assertIsNone( + self.foo_list.get_member('test@example.com').moderation_action) + self.client.login(username='testsu', password='testpass') + response = self.client.post(self.url, { + 'formname': 'moderation', 'moderation_action': 'hold'}) + self.assertRedirects(response, self.url) + self.assertHasSuccessMessage(response) + self.assertEqual( + self.foo_list.get_member('test@example.com').moderation_action, + 'hold') + response = self.client.post(self.url, { + 'formname': 'moderation', 'moderation_action': ''}) + self.assertRedirects(response, self.url) + self.assertHasSuccessMessage(response) + self.assertIsNone( + self.foo_list.get_member('test@example.com').moderation_action)