From b26769984d849a3bfbff8775e8560766d4e80a82 Mon Sep 17 00:00:00 2001 From: Abhilash Raj Date: Mon, 7 Jan 2019 22:07:14 -0800 Subject: [PATCH] Subscription requests should only show ones pending for moderator. This commit filters requests that are waiting for approval from subscriber instead of moderator. Closes #314. --- src/postorius/doc/news.rst | 5 +- ...ttingsTest.test_list_subscription_requests.yaml | 335 +++++++++++++++------ .../tests/mailman_api_tests/test_list_settings.py | 15 +- src/postorius/views/list.py | 4 +- 4 files changed, 268 insertions(+), 91 deletions(-) diff --git a/src/postorius/doc/news.rst b/src/postorius/doc/news.rst index 46abe45a..142852d6 100644 --- a/src/postorius/doc/news.rst +++ b/src/postorius/doc/news.rst @@ -24,7 +24,10 @@ along with Postorius. If not, see . * Expose ``max_num_recipients`` in list settings. (Closes #297) * Add support for Non-member management in Postorius. (Closes #265) -* `Members` tab in Mailing List settings page is now called `Users`. (Closes #309) +* `Members` tab in Mailing List settings page is now called `Users`. + (Closes #309) +* Show pending subscription requests are only pending for Moderator. + (Closes #314) 1.2.2 ===== diff --git a/src/postorius/tests/fixtures/vcr_cassettes/ListSettingsTest.test_list_subscription_requests.yaml b/src/postorius/tests/fixtures/vcr_cassettes/ListSettingsTest.test_list_subscription_requests.yaml index 48e242ee..f0a7b80f 100644 --- a/src/postorius/tests/fixtures/vcr_cassettes/ListSettingsTest.test_list_subscription_requests.yaml +++ b/src/postorius/tests/fixtures/vcr_cassettes/ListSettingsTest.test_list_subscription_requests.yaml @@ -47,12 +47,12 @@ interactions: method: GET uri: http://localhost:9001/3.0/lists/foo.example.com response: - body: {string: '{"display_name": "Foo", "fqdn_listname": "foo@example.com", "http_etag": - "\"698a819bbb6b902096a8c5543cc7fac2328960d5\"", "list_id": "foo.example.com", + body: {string: '{"description": "", "display_name": "Foo", "fqdn_listname": "foo@example.com", + "http_etag": "\"490ba5a3f1642771810284491327932ca01ce4f2\"", "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-length: ['313'] content-type: [application/json; charset=UTF-8] status: {code: 200, message: OK} - request: @@ -67,7 +67,7 @@ interactions: headers: content-length: ['0'] content-type: [application/json; charset=UTF-8] - location: ['http://localhost:9001/3.0/members/700'] + location: ['http://localhost:9001/3.0/members/26'] status: {code: 201, message: Created} - request: body: display_name=None&list_id=foo.example.com&role=moderator&subscriber=moderator%40example.com @@ -81,7 +81,7 @@ interactions: headers: content-length: ['0'] content-type: [application/json; charset=UTF-8] - location: ['http://localhost:9001/3.0/members/701'] + location: ['http://localhost:9001/3.0/members/27'] status: {code: 201, message: Created} - request: body: null @@ -90,12 +90,12 @@ interactions: method: GET uri: http://localhost:9001/3.1/lists/foo.example.com response: - body: {string: '{"display_name": "Foo", "fqdn_listname": "foo@example.com", "http_etag": - "\"4fb667c3d533cf6b2b6faa284a0d5d1302536524\"", "list_id": "foo.example.com", + body: {string: '{"description": "", "display_name": "Foo", "fqdn_listname": "foo@example.com", + "http_etag": "\"0c03b5f44b6fe77375f8f14c2dbe4e2d0219d704\"", "list_id": "foo.example.com", "list_name": "foo", "mail_host": "example.com", "member_count": 0, "self_link": "http://localhost:9001/3.1/lists/foo.example.com", "volume": 1}'} headers: - content-length: ['294'] + content-length: ['313'] content-type: [application/json; charset=UTF-8] status: {code: 200, message: OK} - request: @@ -107,11 +107,11 @@ interactions: response: body: {string: '{"entries": [{"address": "http://localhost:9001/3.1/addresses/owner@example.com", "delivery_mode": "regular", "display_name": "None", "email": "owner@example.com", - "http_etag": "\"910c39df12f5302a70fbbfa9fb5fa78725f2d599\"", "list_id": "foo.example.com", - "member_id": "000000000000000000000000000002bc", "moderation_action": "accept", - "role": "owner", "self_link": "http://localhost:9001/3.1/members/000000000000000000000000000002bc", - "user": "http://localhost:9001/3.1/users/00000000000000000000000000000386"}], - "http_etag": "\"eab250b6e4121c8e539da84bf40089ac28744ebd\"", "start": 0, "total_size": + "http_etag": "\"e1704a41caa7fa38855e6496d92d98ce3f826020\"", "list_id": "foo.example.com", + "member_id": "0000000000000000000000000000001a", "moderation_action": "accept", + "role": "owner", "self_link": "http://localhost:9001/3.1/members/0000000000000000000000000000001a", + "user": "http://localhost:9001/3.1/users/0000000000000000000000000000002e"}], + "http_etag": "\"5b137b40704bb838409fef3fb3b56ec8f141c45f\"", "start": 0, "total_size": 1}'} headers: content-length: ['602'] @@ -126,11 +126,11 @@ interactions: response: body: {string: '{"entries": [{"address": "http://localhost:9001/3.1/addresses/moderator@example.com", "delivery_mode": "regular", "display_name": "None", "email": "moderator@example.com", - "http_etag": "\"82461dd7670fa3e634938a783b8a549fe93491a2\"", "list_id": "foo.example.com", - "member_id": "000000000000000000000000000002bd", "moderation_action": "accept", - "role": "moderator", "self_link": "http://localhost:9001/3.1/members/000000000000000000000000000002bd", - "user": "http://localhost:9001/3.1/users/00000000000000000000000000000387"}], - "http_etag": "\"bea0265657f1685f6d75522adaa26ab67d6f3fd2\"", "start": 0, "total_size": + "http_etag": "\"6ea006d0c7f867378482d00f4d9a78dc05c17137\"", "list_id": "foo.example.com", + "member_id": "0000000000000000000000000000001b", "moderation_action": "accept", + "role": "moderator", "self_link": "http://localhost:9001/3.1/members/0000000000000000000000000000001b", + "user": "http://localhost:9001/3.1/users/0000000000000000000000000000002f"}], + "http_etag": "\"57871c2b3084c43c05b246d3772f24fc64abc270\"", "start": 0, "total_size": 1}'} headers: content-length: ['614'] @@ -143,12 +143,12 @@ interactions: method: GET uri: http://localhost:9001/3.1/lists/foo.example.com response: - body: {string: '{"display_name": "Foo", "fqdn_listname": "foo@example.com", "http_etag": - "\"4fb667c3d533cf6b2b6faa284a0d5d1302536524\"", "list_id": "foo.example.com", + body: {string: '{"description": "", "display_name": "Foo", "fqdn_listname": "foo@example.com", + "http_etag": "\"0c03b5f44b6fe77375f8f14c2dbe4e2d0219d704\"", "list_id": "foo.example.com", "list_name": "foo", "mail_host": "example.com", "member_count": 0, "self_link": "http://localhost:9001/3.1/lists/foo.example.com", "volume": 1}'} headers: - content-length: ['294'] + content-length: ['313'] content-type: [application/json; charset=UTF-8] status: {code: 200, message: OK} - request: @@ -185,23 +185,23 @@ interactions: "no_mitigation", "dmarc_mitigate_unconditionally": false, "dmarc_moderation_notice": "", "dmarc_wrapped_message_text": "", "filter_content": false, "first_strip_reply_to": false, "footer_uri": "", "fqdn_listname": "foo@example.com", "goodbye_message_uri": - "", "header_uri": "", "http_etag": "\"34e76ae06d4d1fba1572e3396847b3fcd1d7740d\"", + "", "header_uri": "", "http_etag": "\"6452634d9d9354d8644770994fcc33515a9e8d0d\"", "include_rfc2369_headers": true, "info": "", "join_address": "foo-join@example.com", "last_post_at": null, "leave_address": "foo-leave@example.com", "list_name": - "foo", "mail_host": "example.com", "max_message_size": 40, "moderator_password": - null, "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", - "require_explicit_destination": true, "respond_to_post_requests": true, "send_welcome_message": - true, "subject_prefix": "[Foo] ", "subscription_policy": "confirm", "volume": - 1, "welcome_message_uri": ""}'} - headers: - content-length: ['2033'] + "foo", "mail_host": "example.com", "max_message_size": 40, "max_num_recipients": + 10, "moderator_password": null, "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", "require_explicit_destination": true, "respond_to_post_requests": + true, "send_welcome_message": true, "subject_prefix": "[Foo] ", "subscription_policy": + "confirm", "volume": 1, "welcome_message_uri": ""}'} + headers: + content-length: ['2059'] content-type: [application/json; charset=UTF-8] status: {code: 200, message: OK} - request: - body: subscription_policy=moderate + body: '' headers: accept-encoding: ['gzip, deflate'] content-type: [application/x-www-form-urlencoded] @@ -213,45 +213,191 @@ interactions: Content-Length: ['0'] status: {code: 204, message: No Content} - request: - body: display_name=None&list_id=foo.example.com&subscriber=test%40example.com + body: display_name=None&list_id=foo.example.com&pre_verified=True&subscriber=someone%40example.com headers: accept-encoding: ['gzip, deflate'] content-type: [application/x-www-form-urlencoded] method: POST uri: http://localhost:9001/3.0/members response: - body: {string: '{"http_etag": "\"c168e026080bfcd57aabfa62e554a5dd14bb08de\"", - "token": "0000000000000000000000000000000000000030", "token_owner": "subscriber"}'} + body: {string: '{"http_etag": "\"194fd4e0ee5e5a5584b6a8236b7c8160c6bc0912\"", + "token": "0000000000000000000000000000000000000043", "token_owner": "subscriber"}'} headers: content-length: ['143'] content-type: [application/json; charset=UTF-8] status: {code: 202, message: Accepted} - request: - body: display_name=None&list_id=foo.example.com&subscriber=owner%40example.com + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: GET + uri: http://localhost:9001/3.1/lists/foo.example.com + response: + body: {string: '{"description": "", "display_name": "Foo", "fqdn_listname": "foo@example.com", + "http_etag": "\"0c03b5f44b6fe77375f8f14c2dbe4e2d0219d704\"", "list_id": "foo.example.com", + "list_name": "foo", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.1/lists/foo.example.com", "volume": 1}'} + headers: + content-length: ['313'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: GET + uri: http://localhost:9001/3.1/lists/foo.example.com/roster/owner + response: + body: {string: '{"entries": [{"address": "http://localhost:9001/3.1/addresses/owner@example.com", + "delivery_mode": "regular", "display_name": "None", "email": "owner@example.com", + "http_etag": "\"e1704a41caa7fa38855e6496d92d98ce3f826020\"", "list_id": "foo.example.com", + "member_id": "0000000000000000000000000000001a", "moderation_action": "accept", + "role": "owner", "self_link": "http://localhost:9001/3.1/members/0000000000000000000000000000001a", + "user": "http://localhost:9001/3.1/users/0000000000000000000000000000002e"}], + "http_etag": "\"5b137b40704bb838409fef3fb3b56ec8f141c45f\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['602'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: GET + uri: http://localhost:9001/3.1/lists/foo.example.com/roster/moderator + response: + body: {string: '{"entries": [{"address": "http://localhost:9001/3.1/addresses/moderator@example.com", + "delivery_mode": "regular", "display_name": "None", "email": "moderator@example.com", + "http_etag": "\"6ea006d0c7f867378482d00f4d9a78dc05c17137\"", "list_id": "foo.example.com", + "member_id": "0000000000000000000000000000001b", "moderation_action": "accept", + "role": "moderator", "self_link": "http://localhost:9001/3.1/members/0000000000000000000000000000001b", + "user": "http://localhost:9001/3.1/users/0000000000000000000000000000002f"}], + "http_etag": "\"57871c2b3084c43c05b246d3772f24fc64abc270\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['614'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: GET + uri: http://localhost:9001/3.1/lists/foo.example.com + response: + body: {string: '{"description": "", "display_name": "Foo", "fqdn_listname": "foo@example.com", + "http_etag": "\"0c03b5f44b6fe77375f8f14c2dbe4e2d0219d704\"", "list_id": "foo.example.com", + "list_name": "foo", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.1/lists/foo.example.com", "volume": 1}'} + headers: + content-length: ['313'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: GET + uri: http://localhost:9001/3.1/lists/foo@example.com/requests + response: + body: {string: '{"entries": [{"display_name": "None", "email": "someone@example.com", + "http_etag": "\"abedc99fe80560f9fc42a8a6bf8287e2417b1147\"", "list_id": "foo.example.com", + "token": "0000000000000000000000000000000000000043", "token_owner": "subscriber", + "type": "subscription", "when": "2005-08-01T07:49:23"}], "http_etag": "\"69580a98f31f31bb42f0ed3db0093b52ab188e25\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['389'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: GET + uri: http://localhost:9001/3.0/lists/foo@example.com/config + response: + body: {string: '{"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_footer_uri": "", "digest_header_uri": "", "digest_last_sent_at": + null, "digest_send_periodic": true, "digest_size_threshold": 30.0, "digest_volume_frequency": + "monthly", "digests_enabled": true, "display_name": "Foo", "dmarc_mitigate_action": + "no_mitigation", "dmarc_mitigate_unconditionally": false, "dmarc_moderation_notice": + "", "dmarc_wrapped_message_text": "", "filter_content": false, "first_strip_reply_to": + false, "footer_uri": "", "fqdn_listname": "foo@example.com", "goodbye_message_uri": + "", "header_uri": "", "http_etag": "\"6452634d9d9354d8644770994fcc33515a9e8d0d\"", + "include_rfc2369_headers": true, "info": "", "join_address": "foo-join@example.com", + "last_post_at": null, "leave_address": "foo-leave@example.com", "list_name": + "foo", "mail_host": "example.com", "max_message_size": 40, "max_num_recipients": + 10, "moderator_password": null, "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", "require_explicit_destination": true, "respond_to_post_requests": + true, "send_welcome_message": true, "subject_prefix": "[Foo] ", "subscription_policy": + "confirm", "volume": 1, "welcome_message_uri": ""}'} + headers: + content-length: ['2059'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: subscription_policy=moderate + headers: + accept-encoding: ['gzip, deflate'] + content-type: [application/x-www-form-urlencoded] + method: PATCH + uri: http://localhost:9001/3.0/lists/foo@example.com/config + response: + body: {string: ''} + headers: + Content-Length: ['0'] + status: {code: 204, message: No Content} +- request: + body: display_name=None&list_id=foo.example.com&pre_verified=True&subscriber=test%40example.com + headers: + accept-encoding: ['gzip, deflate'] + content-type: [application/x-www-form-urlencoded] + method: POST + uri: http://localhost:9001/3.0/members + response: + body: {string: '{"http_etag": "\"eb5f377df4f04dc2cbb57c64ab932cc5f458b60d\"", + "token": "0000000000000000000000000000000000000044", "token_owner": "moderator"}'} + headers: + content-length: ['142'] + content-type: [application/json; charset=UTF-8] + status: {code: 202, message: Accepted} +- request: + body: display_name=None&list_id=foo.example.com&pre_verified=True&subscriber=owner%40example.com headers: accept-encoding: ['gzip, deflate'] content-type: [application/x-www-form-urlencoded] method: POST uri: http://localhost:9001/3.0/members response: - body: {string: '{"http_etag": "\"69d67bb3e947341205c4fead7f2bb7bb50f4d9db\"", - "token": "0000000000000000000000000000000000000031", "token_owner": "subscriber"}'} + body: {string: '{"http_etag": "\"7091ae0708dc6ed6347e33f09461cf4802a65e5f\"", + "token": "0000000000000000000000000000000000000045", "token_owner": "moderator"}'} headers: - content-length: ['143'] + content-length: ['142'] content-type: [application/json; charset=UTF-8] status: {code: 202, message: Accepted} - request: - body: display_name=None&list_id=foo.example.com&subscriber=moderator%40example.com + body: display_name=None&list_id=foo.example.com&pre_verified=True&subscriber=moderator%40example.com headers: accept-encoding: ['gzip, deflate'] content-type: [application/x-www-form-urlencoded] method: POST uri: http://localhost:9001/3.0/members response: - body: {string: '{"http_etag": "\"2f4bcaf3921e2bcfd87e6089a1f25f4232896619\"", - "token": "0000000000000000000000000000000000000032", "token_owner": "subscriber"}'} + body: {string: '{"http_etag": "\"6249ffeb4d4eacefd42bb8f40c1d635cc7cd4770\"", + "token": "0000000000000000000000000000000000000046", "token_owner": "moderator"}'} headers: - content-length: ['143'] + content-length: ['142'] content-type: [application/json; charset=UTF-8] status: {code: 202, message: Accepted} - request: @@ -261,12 +407,12 @@ interactions: method: GET uri: http://localhost:9001/3.1/lists/foo.example.com response: - body: {string: '{"display_name": "Foo", "fqdn_listname": "foo@example.com", "http_etag": - "\"4fb667c3d533cf6b2b6faa284a0d5d1302536524\"", "list_id": "foo.example.com", + body: {string: '{"description": "", "display_name": "Foo", "fqdn_listname": "foo@example.com", + "http_etag": "\"0c03b5f44b6fe77375f8f14c2dbe4e2d0219d704\"", "list_id": "foo.example.com", "list_name": "foo", "mail_host": "example.com", "member_count": 0, "self_link": "http://localhost:9001/3.1/lists/foo.example.com", "volume": 1}'} headers: - content-length: ['294'] + content-length: ['313'] content-type: [application/json; charset=UTF-8] status: {code: 200, message: OK} - request: @@ -278,11 +424,11 @@ interactions: response: body: {string: '{"entries": [{"address": "http://localhost:9001/3.1/addresses/owner@example.com", "delivery_mode": "regular", "display_name": "None", "email": "owner@example.com", - "http_etag": "\"910c39df12f5302a70fbbfa9fb5fa78725f2d599\"", "list_id": "foo.example.com", - "member_id": "000000000000000000000000000002bc", "moderation_action": "accept", - "role": "owner", "self_link": "http://localhost:9001/3.1/members/000000000000000000000000000002bc", - "user": "http://localhost:9001/3.1/users/00000000000000000000000000000386"}], - "http_etag": "\"eab250b6e4121c8e539da84bf40089ac28744ebd\"", "start": 0, "total_size": + "http_etag": "\"e1704a41caa7fa38855e6496d92d98ce3f826020\"", "list_id": "foo.example.com", + "member_id": "0000000000000000000000000000001a", "moderation_action": "accept", + "role": "owner", "self_link": "http://localhost:9001/3.1/members/0000000000000000000000000000001a", + "user": "http://localhost:9001/3.1/users/0000000000000000000000000000002e"}], + "http_etag": "\"5b137b40704bb838409fef3fb3b56ec8f141c45f\"", "start": 0, "total_size": 1}'} headers: content-length: ['602'] @@ -297,11 +443,11 @@ interactions: response: body: {string: '{"entries": [{"address": "http://localhost:9001/3.1/addresses/moderator@example.com", "delivery_mode": "regular", "display_name": "None", "email": "moderator@example.com", - "http_etag": "\"82461dd7670fa3e634938a783b8a549fe93491a2\"", "list_id": "foo.example.com", - "member_id": "000000000000000000000000000002bd", "moderation_action": "accept", - "role": "moderator", "self_link": "http://localhost:9001/3.1/members/000000000000000000000000000002bd", - "user": "http://localhost:9001/3.1/users/00000000000000000000000000000387"}], - "http_etag": "\"bea0265657f1685f6d75522adaa26ab67d6f3fd2\"", "start": 0, "total_size": + "http_etag": "\"6ea006d0c7f867378482d00f4d9a78dc05c17137\"", "list_id": "foo.example.com", + "member_id": "0000000000000000000000000000001b", "moderation_action": "accept", + "role": "moderator", "self_link": "http://localhost:9001/3.1/members/0000000000000000000000000000001b", + "user": "http://localhost:9001/3.1/users/0000000000000000000000000000002f"}], + "http_etag": "\"57871c2b3084c43c05b246d3772f24fc64abc270\"", "start": 0, "total_size": 1}'} headers: content-length: ['614'] @@ -314,12 +460,12 @@ interactions: method: GET uri: http://localhost:9001/3.1/lists/foo.example.com response: - body: {string: '{"display_name": "Foo", "fqdn_listname": "foo@example.com", "http_etag": - "\"4fb667c3d533cf6b2b6faa284a0d5d1302536524\"", "list_id": "foo.example.com", + body: {string: '{"description": "", "display_name": "Foo", "fqdn_listname": "foo@example.com", + "http_etag": "\"0c03b5f44b6fe77375f8f14c2dbe4e2d0219d704\"", "list_id": "foo.example.com", "list_name": "foo", "mail_host": "example.com", "member_count": 0, "self_link": "http://localhost:9001/3.1/lists/foo.example.com", "volume": 1}'} headers: - content-length: ['294'] + content-length: ['313'] content-type: [application/json; charset=UTF-8] status: {code: 200, message: OK} - request: @@ -329,20 +475,23 @@ interactions: method: GET uri: http://localhost:9001/3.1/lists/foo@example.com/requests response: - body: {string: '{"entries": [{"display_name": "None", "email": "test@example.com", - "http_etag": "\"81e0491cb7555726b9a8ea61bb921afba18ea87c\"", "list_id": "foo.example.com", - "token": "0000000000000000000000000000000000000030", "token_owner": "subscriber", + body: {string: '{"entries": [{"display_name": "None", "email": "someone@example.com", + "http_etag": "\"abedc99fe80560f9fc42a8a6bf8287e2417b1147\"", "list_id": "foo.example.com", + "token": "0000000000000000000000000000000000000043", "token_owner": "subscriber", "type": "subscription", "when": "2005-08-01T07:49:23"}, {"display_name": "None", - "email": "owner@example.com", "http_etag": "\"7dc94f7adedf264535456e506c66b2efa7be3b36\"", - "list_id": "foo.example.com", "token": "0000000000000000000000000000000000000031", - "token_owner": "subscriber", "type": "subscription", "when": "2005-08-01T07:49:23"}, - {"display_name": "None", "email": "moderator@example.com", "http_etag": "\"c47c1e77786da995f278990490d5aa33b7226940\"", - "list_id": "foo.example.com", "token": "0000000000000000000000000000000000000032", - "token_owner": "subscriber", "type": "subscription", "when": "2005-08-01T07:49:23"}], - "http_etag": "\"c148af7d2d86af0e296a1666c71432da71209d5f\"", "start": 0, "total_size": - 3}'} - headers: - content-length: ['958'] + "email": "test@example.com", "http_etag": "\"0485b71fec98aad5b263562640b82d67b0bcda2c\"", + "list_id": "foo.example.com", "token": "0000000000000000000000000000000000000044", + "token_owner": "moderator", "type": "subscription", "when": "2005-08-01T07:49:23"}, + {"display_name": "None", "email": "owner@example.com", "http_etag": "\"184121cc8b0300357ae205ec897935234626364d\"", + "list_id": "foo.example.com", "token": "0000000000000000000000000000000000000045", + "token_owner": "moderator", "type": "subscription", "when": "2005-08-01T07:49:23"}, + {"display_name": "None", "email": "moderator@example.com", "http_etag": "\"e81c4f7c8b0645c541cb3c80b28fae88825ebf00\"", + "list_id": "foo.example.com", "token": "0000000000000000000000000000000000000046", + "token_owner": "moderator", "type": "subscription", "when": "2005-08-01T07:49:23"}], + "http_etag": "\"92965f1b9a81e801339c0facd6bdbbb48598f7fe\"", "start": 0, "total_size": + 4}'} + headers: + content-length: ['1241'] content-type: [application/json; charset=UTF-8] status: {code: 200, message: OK} - request: @@ -380,17 +529,20 @@ interactions: uri: http://localhost:9001/3.0/users response: body: {string: '{"entries": [{"created_on": "2005-08-01T07:49:23", "display_name": - "None", "http_etag": "\"4e44fc5d46397c0ec8b8ed65327a43daebaaa998\"", "is_server_owner": - false, "self_link": "http://localhost:9001/3.0/users/902", "user_id": 902}, + "None", "http_etag": "\"5e715f5018b7e9ad8d263714c2c39b0c2cc24a50\"", "is_server_owner": + false, "self_link": "http://localhost:9001/3.0/users/46", "user_id": 46}, {"created_on": "2005-08-01T07:49:23", "display_name": "None", "http_etag": - "\"76285088a1f6627751d332994bfd752b8aae6321\"", "is_server_owner": false, - "self_link": "http://localhost:9001/3.0/users/903", "user_id": 903}, {"created_on": - "2005-08-01T07:49:23", "display_name": "None", "http_etag": "\"71dcb47a73d60c1dbc3788007315cadb08f15678\"", - "is_server_owner": false, "self_link": "http://localhost:9001/3.0/users/904", - "user_id": 904}], "http_etag": "\"d49083d662382e2d274171733033dc3345eebe80\"", - "start": 0, "total_size": 3}'} - headers: - content-length: ['757'] + "\"a5dcd6f955edf6abf9efe964a2b11a16cc8ea4de\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/47", "user_id": 47}, {"created_on": + "2005-08-01T07:49:23", "display_name": "None", "http_etag": "\"a2a496bb6ea9f10b7c62b3d9e1b2ebe85057ff97\"", + "is_server_owner": false, "self_link": "http://localhost:9001/3.0/users/48", + "user_id": 48}, {"created_on": "2005-08-01T07:49:23", "display_name": "None", + "http_etag": "\"c8e5aaeed4410a8eaf1f0958f0b9ed66777e8e6b\"", "is_server_owner": + false, "self_link": "http://localhost:9001/3.0/users/49", "user_id": 49}], + "http_etag": "\"452098b166af9cb2967867611c9345fab7cb38d8\"", "start": 0, "total_size": + 4}'} + headers: + content-length: ['967'] content-type: [application/json; charset=UTF-8] status: {code: 200, message: OK} - request: @@ -398,7 +550,18 @@ interactions: headers: accept-encoding: ['gzip, deflate'] method: DELETE - uri: http://localhost:9001/3.0/users/902 + uri: http://localhost:9001/3.0/users/46 + response: + body: {string: ''} + headers: + Content-Length: ['0'] + status: {code: 204, message: No Content} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: DELETE + uri: http://localhost:9001/3.0/users/47 response: body: {string: ''} headers: @@ -409,7 +572,7 @@ interactions: headers: accept-encoding: ['gzip, deflate'] method: DELETE - uri: http://localhost:9001/3.0/users/903 + uri: http://localhost:9001/3.0/users/48 response: body: {string: ''} headers: @@ -420,7 +583,7 @@ interactions: headers: accept-encoding: ['gzip, deflate'] method: DELETE - uri: http://localhost:9001/3.0/users/904 + uri: http://localhost:9001/3.0/users/49 response: body: {string: ''} headers: 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 32d6cd69..5701a620 100644 --- a/src/postorius/tests/mailman_api_tests/test_list_settings.py +++ b/src/postorius/tests/mailman_api_tests/test_list_settings.py @@ -192,13 +192,22 @@ class ListSettingsTest(ViewTestCase): b'There are currently no subscription requests for this list.' in response.content) self.assertNotContains(response, '
') + # We set subscription policy to 'confirm', which should wait for the + # user approval. + self.foo_list.settings['subscription_policy'] = 'confirm' + self.foo_list.settings.save() + self.foo_list.subscribe('someone@example.com', pre_verified=True) + response = self.client.get(url) + self.assertEqual(response.status_code, 200) + # Check that the request is not shown in pending subscription requests. + self.assertTrue('someone@example.com' not in str(response.content)) # Now we set the subscription policy to moderate so that all # subscriptions are held for moderator approval. self.foo_list.settings['subscription_policy'] = 'moderate' self.foo_list.settings.save() - self.foo_list.subscribe('test@example.com') - self.foo_list.subscribe('owner@example.com') - self.foo_list.subscribe('moderator@example.com') + self.foo_list.subscribe('test@example.com', pre_verified=True) + self.foo_list.subscribe('owner@example.com', pre_verified=True) + self.foo_list.subscribe('moderator@example.com', pre_verified=True) # Now there should be three subscription requests pending. response = self.client.get(url) self.assertEqual(response.status_code, 200) diff --git a/src/postorius/views/list.py b/src/postorius/views/list.py index f2280200..cfd42f2e 100644 --- a/src/postorius/views/list.py +++ b/src/postorius/views/list.py @@ -735,7 +735,9 @@ def list_subscription_requests(request, list_id): """Shows a list of subscription requests. """ m_list = List.objects.get_or_404(fqdn_listname=list_id) - requests = m_list.requests + requests = [req + for req in m_list.requests + if req['token_owner'] == 'moderator'] paginated_requests = paginate( requests, request.GET.get('page'), -- 2.11.4.GIT