diff options
| author | Barry Warsaw | 2015-11-15 15:37:19 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2015-11-15 15:37:19 -0500 |
| commit | e2c50f1e10a485a79183e99e0e78b93673b8a8a7 (patch) | |
| tree | f21f549b83eeb0296a2b88a52f6b5520f3817381 /src | |
| parent | 9975ac00206e70da7d7c9bebf9d22192bafb88ac (diff) | |
| download | mailman-e2c50f1e10a485a79183e99e0e78b93673b8a8a7.tar.gz mailman-e2c50f1e10a485a79183e99e0e78b93673b8a8a7.tar.zst mailman-e2c50f1e10a485a79183e99e0e78b93673b8a8a7.zip | |
Diffstat (limited to 'src')
| -rw-r--r-- | src/mailman/docs/NEWS.rst | 1 | ||||
| -rw-r--r-- | src/mailman/rest/docs/post-moderation.rst | 2 | ||||
| -rw-r--r-- | src/mailman/rest/post_moderation.py | 15 |
3 files changed, 11 insertions, 7 deletions
diff --git a/src/mailman/docs/NEWS.rst b/src/mailman/docs/NEWS.rst index dddbfd1e1..da8ede64f 100644 --- a/src/mailman/docs/NEWS.rst +++ b/src/mailman/docs/NEWS.rst @@ -95,6 +95,7 @@ REST link the address to the user. Given by Abhilash Raj. * Fix pagination values `start` and `total_size` in the REST API. Given by Aurélien Bompard. (Closes: #154) + * JSON representations for held message now include a ``self_link``. Other ----- diff --git a/src/mailman/rest/docs/post-moderation.rst b/src/mailman/rest/docs/post-moderation.rst index c6720339c..8a1bdd2e4 100644 --- a/src/mailman/rest/docs/post-moderation.rst +++ b/src/mailman/rest/docs/post-moderation.rst @@ -83,6 +83,7 @@ message. This will include the text of the message. <BLANKLINE> reason: Because request_id: 1 + self_link: http://localhost:9001/3.0/lists/ant.example.com/held/1 sender: anne@example.com subject: Something @@ -127,6 +128,7 @@ The message is still in the moderation queue. <BLANKLINE> reason: Because request_id: 1 + self_link: http://localhost:9001/3.0/lists/ant.example.com/held/1 sender: anne@example.com subject: Something diff --git a/src/mailman/rest/post_moderation.py b/src/mailman/rest/post_moderation.py index 77d81fa15..207294e7d 100644 --- a/src/mailman/rest/post_moderation.py +++ b/src/mailman/rest/post_moderation.py @@ -28,7 +28,8 @@ from mailman.interfaces.action import Action from mailman.interfaces.messages import IMessageStore from mailman.interfaces.requests import IListRequests, RequestType from mailman.rest.helpers import ( - CollectionMixin, bad_request, child, etag, no_content, not_found, okay) + CollectionMixin, bad_request, child, etag, no_content, not_found, okay, + path_to) from mailman.rest.validator import Validator, enum_validator from zope.component import getUtility @@ -56,6 +57,10 @@ class _ModerationBase: # record's row id, which isn't helpful at all. If it's not there, # that's fine too. resource.pop('id', None) + # Add a self_link. + resource['self_link'] = path_to( + 'lists/{}/held/{}'.format(self._mlist.list_id, request_id), + self.api_version) return resource @@ -64,7 +69,7 @@ class _HeldMessageBase(_ModerationBase): """Held messages are a little different.""" def _make_resource(self, request_id): - resource = super(_HeldMessageBase, self)._make_resource(request_id) + resource = super()._make_resource(request_id) if resource is None: return None # Grab the message and insert its text representation into the @@ -137,11 +142,7 @@ class HeldMessages(_HeldMessageBase, CollectionMixin): def _resource_as_dict(self, request): """See `CollectionMixin`.""" - resource = self._make_resource(request.id) - if resource is not None: - resource['self_link'] = self.path_to('lists/{0}/held/{1}'.format( - self._mlist.list_id, resource['request_id'])) - return resource + return self._make_resource(request.id) def _get_collection(self, request): requests = IListRequests(self._mlist) |
