summaryrefslogtreecommitdiff
path: root/src/mailman/rest/users.py
diff options
context:
space:
mode:
authorAbhilash Raj2015-03-21 00:32:10 +0530
committerAbhilash Raj2015-03-21 00:32:10 +0530
commitae2a7c9a22f5b6eeed1a6884c6dcd87ed9ba673d (patch)
tree270cef8ecb93fba8eaee33381f1415c54fd7af60 /src/mailman/rest/users.py
parent6280c5ffcd2fdebf80f170f7c9a4e47adf0c6c4a (diff)
downloadmailman-ae2a7c9a22f5b6eeed1a6884c6dcd87ed9ba673d.tar.gz
mailman-ae2a7c9a22f5b6eeed1a6884c6dcd87ed9ba673d.tar.zst
mailman-ae2a7c9a22f5b6eeed1a6884c6dcd87ed9ba673d.zip
Diffstat (limited to 'src/mailman/rest/users.py')
-rw-r--r--src/mailman/rest/users.py36
1 files changed, 33 insertions, 3 deletions
diff --git a/src/mailman/rest/users.py b/src/mailman/rest/users.py
index 018c8441d..b1aca9678 100644
--- a/src/mailman/rest/users.py
+++ b/src/mailman/rest/users.py
@@ -67,8 +67,9 @@ CREATION_FIELDS = dict(
email=str,
display_name=str,
password=str,
- _optional=('display_name', 'password'),
- )
+ is_serverowner=bool,
+ _optional=('display_name', 'password', 'is_serverowner'),
+)
@@ -108,7 +109,8 @@ class _UserBase(CollectionMixin):
user_id=user_id,
created_on=user.created_on,
self_link=path_to('users/{}'.format(user_id)),
- )
+ is_serverowner=user.is_serverowner,
+ )
# Add the password attribute, only if the user has a password. Same
# with the real name. These could be None or the empty string.
if user.password:
@@ -377,3 +379,31 @@ class Login:
no_content(response)
else:
forbidden(response)
+
+class OwnersForDomain(_UserBase):
+ """Owners for a particular domain."""
+
+ def __init__(self, domain):
+ self._domain = domain
+
+ def on_get(self, request, response):
+ """/domains/<domain>/owners"""
+ resource = self._make_collection(request)
+ okay(response, etag(resource))
+
+ def on_post(self, request, response):
+ """POST to /domains/<domain>/owners """
+ validator = Validator(owner_id=GetterSetter(int))
+ try:
+ values = validator(request)
+ except ValueError as error:
+ bad_request(response, str(error))
+ return
+ owner = getUtility(IUserManager).get_user_by_id(values['owner_id'])
+ self._domain.add_owner(owner)
+ return no_content(response)
+
+ @paginate
+ def _get_collection(self, request):
+ """See `CollectionMixin`."""
+ return list(self._domain.owners)