Barry Warsaw pushed to branch master at mailman / Mailman
Commits:
9975ac00 by Aurélien Bompard at 2015-11-15T15:10:42Z
REST: add a self_link entry to held messages
- - - - -
e2c50f1e by Barry Warsaw at 2015-11-15T15:37:19Z
JSON representations for held message now include a ``self_link``.
- - - - -
3 changed files:
- src/mailman/docs/NEWS.rst
- src/mailman/rest/docs/post-moderation.rst
- src/mailman/rest/post_moderation.py
Changes:
=====================================
src/mailman/docs/NEWS.rst
=====================================
--- 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
-----
=====================================
src/mailman/rest/docs/post-moderation.rst
=====================================
--- a/src/mailman/rest/docs/post-moderation.rst
+++ b/src/mailman/rest/docs/post-moderation.rst
@@ -52,6 +52,7 @@ When a message gets held for moderator approval, it shows up
in this list.
<BLANKLINE>
reason: Because
request_id: 1
+ self_link: http://localhost:9001/3.0/lists/ant.example.com/held/1
sender: [email protected]
subject: Something
http_etag: "..."
@@ -82,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: [email protected]
subject: Something
@@ -126,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: [email protected]
subject: Something
=====================================
src/mailman/rest/post_moderation.py
=====================================
--- 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
View it on GitLab:
https://gitlab.com/mailman/mailman/compare/29947f0ef5667490f704b558c2acea653cabdca9...e2c50f1e10a485a79183e99e0e78b93673b8a8a7
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe:
https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org