Commit 43e0d1d6 authored by Jérome Perrin's avatar Jérome Perrin

officejs_support_request_ui: Support events with non accessible sender in RSS

To be consistent with slapos.core RSS and default values of fields
in ERP5, where we only check the permission on the "context" document
and tolerate displaying properties of context document even if
accessing some properties of related documents caused an error.

See also slapos.core!433
parent 34b77150
...@@ -50,10 +50,10 @@ for brain in portal.portal_simulation.getMovementHistoryList( ...@@ -50,10 +50,10 @@ for brain in portal.portal_simulation.getMovementHistoryList(
# XXX or {author} commented on {support_request} / {author} opened new Ticket: {support_request} ? # XXX or {author} commented on {support_request} / {author} opened new Ticket: {support_request} ?
'title': support_request_title, 'title': support_request_title,
'category': support_request_category, 'category': support_request_category,
'author': brain.node_title, 'author': event.getSourceTitle(checked_permission="View"),
'link': support_request_link, 'link': support_request_link,
'description': event.asStrippedHTML(), 'description': event.asStrippedHTML(),
'pubDate': brain.date, 'pubDate': event.getStartDate(),
'guid': event.getSourceReference() or event.absolute_url(), 'guid': event.getSourceReference() or event.absolute_url(),
'thumbnail': ( # XXX this is not really a thumbnail, but it's what RSS style uses for <enclosure/> 'thumbnail': ( # XXX this is not really a thumbnail, but it's what RSS style uses for <enclosure/>
# Also, with this `thumbnail` it will look good for image, and most of the time # Also, with this `thumbnail` it will look good for image, and most of the time
......
...@@ -574,6 +574,27 @@ class TestSupportRequestRSSSNonVisibleSupportRequest(SupportRequestRSSTestCase, ...@@ -574,6 +574,27 @@ class TestSupportRequestRSSSNonVisibleSupportRequest(SupportRequestRSSTestCase,
self.assertFalse(rss.bozo) self.assertFalse(rss.bozo)
class TestSupportRequestRSSSNonVisibleSender(SupportRequestRSSTestCase, DefaultTestRSSMixin):
"""Edge case test for support request RSS for an event (visible by user) by a sender not visible by user.
"""
def afterSetUp(self):
super(TestSupportRequestRSSSNonVisibleSender, self).afterSetUp()
unknown_sender = self.portal.person_module.newContent()
unknown_sender.manage_permission('View', ['Manager'], 0)
unknown_sender.manage_permission('Access contents information', ['Manager'], 0)
self.event.setSourceValue(unknown_sender)
self.tic()
def _checkRSS(self, response):
self.assertEqual(httplib.OK, response.getStatus())
rss = feedparser.parse(response.getBody())
item, = rss.entries
# no author for this event, because sender could not be access
self.assertFalse(item.get('author'))
# https://pythonhosted.org/feedparser/bozo.html#advanced-bozo
self.assertFalse(rss.bozo)
class TestSupportRequestRSSSNonVisibleAttachment(SupportRequestRSSTestCase, DefaultTestRSSMixin): class TestSupportRequestRSSSNonVisibleAttachment(SupportRequestRSSTestCase, DefaultTestRSSMixin):
"""Edge case test for support request RSS for an event (visible by user) with attachment not visible by user. """Edge case test for support request RSS for an event (visible by user) with attachment not visible by user.
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment