Use absorb_existing when adding an address
...and fix the response page.
1 parent d553ea8 commit 9d638b652a80a023dcc0c203b7f74adfd60e6673
@Aurélien Bompard Aurélien Bompard authored on 30 Jun 2015
Showing 4 changed files
View
7
src/postorius/forms.py
raise forms.ValidationError(
_('This email is in use. Please choose another or contact'
' the administrator'), 'error')
 
# Check if the email is attached to a user in Mailman
try:
utils.get_client().get_user(email)
raise forms.ValidationError(
_('This email already belongs to a user'), 'error')
except HTTPError:
pass
return email
 
 
class ChangeDisplayNameForm(forms.Form):
View
260
src/postorius/tests/fixtures/vcr_cassettes/TestAddressActivationLinkSuccess.test_existing_user.yaml 0 → 100644
interactions:
- request:
body: email=ler%40example.org&password=None
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']
location: ['http://localhost:9001/3.0/users/36']
status: {code: 201, message: Created}
- request:
body: email=les%40example.org&password=None
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']
location: ['http://localhost:9001/3.0/users/37']
status: {code: 201, message: Created}
- request:
body: null
headers:
accept-encoding: ['gzip, deflate']
method: !!python/unicode GET
uri: http://localhost:9001/3.0/users/ler@example.org
response:
body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag":
"\"80be5db66e58bc06266ab6933e273d69ed62a895\"", "is_server_owner": false,
"password": "$6$rounds=712780$M0l.sgxEzkzCeDYD$2LFDRYejEvpjysYXJG6dq5eycN1GUr1lf/pWTiV/jGP77Nc3l2YJQXF40VSUwZf1Nti/o3sianZSyq4rIYSbd/",
"self_link": "http://localhost:9001/3.0/users/36", "user_id": 36}'}
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/36/addresses
response:
body: {string: !!python/unicode '{"entries": [{"email": "ler@example.org", "http_etag":
"\"200edc8cd699f99ec37a93e5ee6001d7a94a934c\"", "original_email": "ler@example.org",
"registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/ler@example.org",
"user": "http://localhost:9001/3.0/users/36"}], "http_etag": "\"d4e56c1333a0709562bb8597b88e71706e5a196d\"",
"start": 0, "total_size": 1}'}
headers:
content-length: ['385']
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/ler@example.org
response:
body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag":
"\"80be5db66e58bc06266ab6933e273d69ed62a895\"", "is_server_owner": false,
"password": "$6$rounds=712780$M0l.sgxEzkzCeDYD$2LFDRYejEvpjysYXJG6dq5eycN1GUr1lf/pWTiV/jGP77Nc3l2YJQXF40VSUwZf1Nti/o3sianZSyq4rIYSbd/",
"self_link": "http://localhost:9001/3.0/users/36", "user_id": 36}'}
headers:
content-length: ['326']
content-type: [application/json; charset=utf-8]
status: {code: 200, message: OK}
- request:
body: email=les%40example.org&absorb_existing=1
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/36/addresses
response:
body: {string: !!python/unicode ''}
headers:
content-length: ['0']
location: ['http://localhost:9001/3.0/addresses/les@example.org']
status: {code: 201, message: Created}
- request:
body: null
headers:
accept-encoding: ['gzip, deflate']
method: !!python/unicode POST
uri: http://localhost:9001/3.0/addresses/les@example.org/verify
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/ler@example.org
response:
body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag":
"\"80be5db66e58bc06266ab6933e273d69ed62a895\"", "is_server_owner": false,
"password": "$6$rounds=712780$M0l.sgxEzkzCeDYD$2LFDRYejEvpjysYXJG6dq5eycN1GUr1lf/pWTiV/jGP77Nc3l2YJQXF40VSUwZf1Nti/o3sianZSyq4rIYSbd/",
"self_link": "http://localhost:9001/3.0/users/36", "user_id": 36}'}
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/36/addresses
response:
body: {string: !!python/unicode '{"entries": [{"email": "ler@example.org", "http_etag":
"\"200edc8cd699f99ec37a93e5ee6001d7a94a934c\"", "original_email": "ler@example.org",
"registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/ler@example.org",
"user": "http://localhost:9001/3.0/users/36"}, {"email": "les@example.org",
"http_etag": "\"fb740ff55957047e74c6156941ec9837f60581d1\"", "original_email":
"les@example.org", "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/les@example.org",
"user": "http://localhost:9001/3.0/users/36", "verified_on": "2005-08-01T07:49:23"}],
"http_etag": "\"d8edcc475fdd38e064eaaa0d8aa9a461ccafca36\"", "start": 0, "total_size":
2}'}
headers:
content-length: ['705']
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/ler@example.org
response:
body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag":
"\"80be5db66e58bc06266ab6933e273d69ed62a895\"", "is_server_owner": false,
"password": "$6$rounds=712780$M0l.sgxEzkzCeDYD$2LFDRYejEvpjysYXJG6dq5eycN1GUr1lf/pWTiV/jGP77Nc3l2YJQXF40VSUwZf1Nti/o3sianZSyq4rIYSbd/",
"self_link": "http://localhost:9001/3.0/users/36", "user_id": 36}'}
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/36/addresses
response:
body: {string: !!python/unicode '{"entries": [{"email": "ler@example.org", "http_etag":
"\"200edc8cd699f99ec37a93e5ee6001d7a94a934c\"", "original_email": "ler@example.org",
"registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/ler@example.org",
"user": "http://localhost:9001/3.0/users/36"}, {"email": "les@example.org",
"http_etag": "\"fb740ff55957047e74c6156941ec9837f60581d1\"", "original_email":
"les@example.org", "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/les@example.org",
"user": "http://localhost:9001/3.0/users/36", "verified_on": "2005-08-01T07:49:23"}],
"http_etag": "\"d8edcc475fdd38e064eaaa0d8aa9a461ccafca36\"", "start": 0, "total_size":
2}'}
headers:
content-length: ['705']
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/ler@example.org
response:
body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag":
"\"80be5db66e58bc06266ab6933e273d69ed62a895\"", "is_server_owner": false,
"password": "$6$rounds=712780$M0l.sgxEzkzCeDYD$2LFDRYejEvpjysYXJG6dq5eycN1GUr1lf/pWTiV/jGP77Nc3l2YJQXF40VSUwZf1Nti/o3sianZSyq4rIYSbd/",
"self_link": "http://localhost:9001/3.0/users/36", "user_id": 36}'}
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/36
response:
body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag":
"\"80be5db66e58bc06266ab6933e273d69ed62a895\"", "is_server_owner": false,
"password": "$6$rounds=712780$M0l.sgxEzkzCeDYD$2LFDRYejEvpjysYXJG6dq5eycN1GUr1lf/pWTiV/jGP77Nc3l2YJQXF40VSUwZf1Nti/o3sianZSyq4rIYSbd/",
"self_link": "http://localhost:9001/3.0/users/36", "user_id": 36}'}
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/36/addresses
response:
body: {string: !!python/unicode '{"entries": [{"email": "ler@example.org", "http_etag":
"\"200edc8cd699f99ec37a93e5ee6001d7a94a934c\"", "original_email": "ler@example.org",
"registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/ler@example.org",
"user": "http://localhost:9001/3.0/users/36"}, {"email": "les@example.org",
"http_etag": "\"fb740ff55957047e74c6156941ec9837f60581d1\"", "original_email":
"les@example.org", "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/les@example.org",
"user": "http://localhost:9001/3.0/users/36", "verified_on": "2005-08-01T07:49:23"}],
"http_etag": "\"d8edcc475fdd38e064eaaa0d8aa9a461ccafca36\"", "start": 0, "total_size":
2}'}
headers:
content-length: ['705']
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 '{"http_etag": "\"32223434a0f3af4cdc4673d1fbc5bac1f6d98fd3\"",
"start": 0, "total_size": 0}'}
headers:
content-length: ['90']
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
response:
body: {string: !!python/unicode '{"entries": [{"created_on": "2005-08-01T07:49:23",
"http_etag": "\"1c5db752cf25d65b8c5628f240cfc2a77ba33ded\"", "is_server_owner":
false, "password": "$6$rounds=698089$Gt7kUt0Gsn4ZEduV$DQBhVSJMs/yN9VMYJ6GVja11SxdW8bYDya91Xf5C9Le7ejStwuJIdc2.kYsyrJQG09OGw2fnizsKfnEs.9udA1",
"self_link": "http://localhost:9001/3.0/users/36", "user_id": 36}], "http_etag":
"\"a9de2de6a6c0e925565f35e4e5458cd60cdc9826\"", "start": 0, "total_size":
1}'}
headers:
content-length: ['429']
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/36
response:
body: {string: !!python/unicode ''}
headers:
content-length: ['0']
status: {code: 204, message: No Content}
version: 1
View
src/postorius/tests/mailman_api_tests/test_address_activation.py
View
src/postorius/views/user.py