REST: creating a user from an existing address
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
GNU Mailman |
Fix Released
|
High
|
Barry Warsaw |
Bug Description
I'm trying to create a User in Mailman 3 from an existing Address. The existing address is currently unlinked and unverified, and I'd like to create a user and link it to it
Here's what Barry suggests :
You might want to create the user and link to it from the existing address resource, i.e. the AnAddress class.
Right now, you cannot get directly from the address to its linked user, if it has one. Look at _AddressBase.
Sketching out an approach:
- The address resource would gain a `user` key if there is a linked user. This would be a url to the user resource. If the address is unlinked, then there would be no such key.
- AnAddress would gain a /user sub-resource which would either 404 if the address is unlinked or return the linked user's JSON data.
- POSTing to /addresses/
Additional use cases to consider:
Q. What if the address is already linked and you want to unlink it?
A. DELETE on the /addresses/
Q. What if you want to change the user the address is linked to?
A. Currently, it's two operations: DELETE the existing link as above, then see below. The other option is to allow a PUT on the /addresses/
Q. What if you want to link the unlinked address to an existing user?
A. Maybe allow this in the POST to /addresses/
It's possibly you'd want to include POST boolean that specifies whether creating a new user is okay or not, with the appropriate response codes in the false case.
Related branches
- Mailman Coders: Pending requested
-
Diff: 103 lines (+81/-3)2 files modifiedsrc/mailman/model/tests/test_usermanager.py (+67/-0)
src/mailman/model/usermanager.py (+14/-3)
- Barry Warsaw: Approve
-
Diff: 424 lines (+274/-21)5 files modifiedsrc/mailman/rest/addresses.py (+10/-0)
src/mailman/rest/docs/addresses.rst (+5/-0)
src/mailman/rest/docs/users.rst (+4/-0)
src/mailman/rest/tests/test_addresses.py (+136/-0)
src/mailman/rest/users.py (+119/-21)
tags: | added: mailman3 |
Changed in mailman: | |
milestone: | none → 3.0.0b5 |
assignee: | nobody → Barry Warsaw (barry) |
importance: | Undecided → High |
status: | New → In Progress |
Changed in mailman: | |
status: | In Progress → Fix Committed |
Changed in mailman: | |
status: | Fix Committed → Fix Released |
I faced this problem and worked on it, i share...
Implementation lacks but we could keep and complete tests, as they seems to fit the use case.
Barry's approach is elegant and i beleive it should be available for the next release as it's a gripping point which comes very early in user experience (the reason of my hack, from the feedbacks of a demo I organized)