summaryrefslogtreecommitdiff
path: root/src/mailman/rest/domains.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/domains.py
parent6280c5ffcd2fdebf80f170f7c9a4e47adf0c6c4a (diff)
downloadmailman-ae2a7c9a22f5b6eeed1a6884c6dcd87ed9ba673d.tar.gz
mailman-ae2a7c9a22f5b6eeed1a6884c6dcd87ed9ba673d.tar.zst
mailman-ae2a7c9a22f5b6eeed1a6884c6dcd87ed9ba673d.zip
Diffstat (limited to 'src/mailman/rest/domains.py')
-rw-r--r--src/mailman/rest/domains.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/mailman/rest/domains.py b/src/mailman/rest/domains.py
index 345e8327d..d312737df 100644
--- a/src/mailman/rest/domains.py
+++ b/src/mailman/rest/domains.py
@@ -29,6 +29,7 @@ from mailman.rest.helpers import (
BadRequest, CollectionMixin, NotFound, bad_request, child, created, etag,
no_content, not_found, okay, path_to)
from mailman.rest.lists import ListsForDomain
+from mailman.rest.users import OwnersForDomain
from mailman.rest.validator import Validator
from zope.component import getUtility
@@ -41,7 +42,6 @@ class _DomainBase(CollectionMixin):
"""See `CollectionMixin`."""
return dict(
base_url=domain.base_url,
- contact_address=domain.contact_address,
description=domain.description,
mail_host=domain.mail_host,
self_link=path_to('domains/{0}'.format(domain.mail_host)),
@@ -88,6 +88,17 @@ class ADomain(_DomainBase):
else:
return BadRequest(), []
+ @child()
+ def owners(self, request, segments):
+ """/domains/<domain>/owners"""
+ if len(segments) == 0:
+ domain = getUtility(IDomainManager).get(self._domain)
+ if domain is None:
+ return NotFound()
+ return OwnersForDomain(domain)
+ else:
+ return BadRequest(), []
+
class AllDomains(_DomainBase):
"""The domains."""
@@ -99,12 +110,12 @@ class AllDomains(_DomainBase):
validator = Validator(mail_host=str,
description=str,
base_url=str,
- contact_address=str,
+ owner_id=int,
_optional=('description', 'base_url',
- 'contact_address'))
+ 'owner_id'))
domain = domain_manager.add(**validator(request))
- except BadDomainSpecificationError:
- bad_request(response, b'Domain exists')
+ except BadDomainSpecificationError as error:
+ bad_request(response, str(error))
except ValueError as error:
bad_request(response, str(error))
else: