2010-09-06 12:38:54 +02:00
|
|
|
from Acquisition import aq_inner, aq_parent
|
2010-01-18 10:54:27 +01:00
|
|
|
|
|
|
|
from Products.Five.browser import BrowserView
|
2012-03-14 23:01:17 +01:00
|
|
|
from Products.CMFCore.utils import getToolByName
|
2010-01-18 10:54:27 +01:00
|
|
|
|
2012-01-14 07:47:07 +01:00
|
|
|
|
2010-01-18 10:54:27 +01:00
|
|
|
class View(BrowserView):
|
|
|
|
"""Comment View.
|
|
|
|
|
2010-12-16 00:52:56 +01:00
|
|
|
When the view of a comment object is called directly, redirect to the
|
2010-09-06 12:38:54 +02:00
|
|
|
the page (content object) and the location (HTML-anchor) where the comment
|
|
|
|
has been posted.
|
2010-12-16 00:52:56 +01:00
|
|
|
|
2010-09-06 12:38:54 +02:00
|
|
|
Redirect from the comment object URL
|
|
|
|
"/path/to/object/++conversation++default/123456789" to the content object
|
2010-12-16 00:52:56 +01:00
|
|
|
where the comment has been posted appended by an HTML anchor that points to
|
2010-09-06 12:38:54 +02:00
|
|
|
the comment "/path/to/object#comment-123456789".
|
2010-12-16 00:52:56 +01:00
|
|
|
|
2010-09-06 12:38:54 +02:00
|
|
|
Context is the comment object. The parent of the comment object is the
|
|
|
|
conversation. The parent of the conversation is the content object where
|
|
|
|
the comment has been posted.
|
2010-01-18 10:54:27 +01:00
|
|
|
"""
|
|
|
|
|
|
|
|
def __call__(self):
|
2010-09-06 12:38:54 +02:00
|
|
|
context = aq_inner(self.context)
|
2012-03-14 23:01:17 +01:00
|
|
|
ptool = getToolByName(context, 'portal_properties')
|
|
|
|
view_action_types = ptool.site_properties.typesUseViewActionInListings
|
|
|
|
obj = aq_parent(aq_parent(context))
|
|
|
|
url = obj.absolute_url()
|
|
|
|
|
|
|
|
"""
|
|
|
|
Image and File types, as well as many other customized archetypes
|
|
|
|
require /view be appended to the url to see the comments, otherwise it
|
|
|
|
will redirect right to the binary object, bypassing comments.
|
|
|
|
"""
|
|
|
|
if obj.portal_type in view_action_types:
|
|
|
|
url = "%s/view" % url
|
|
|
|
|
|
|
|
self.request.response.redirect('%s#%s' % (url, context.id))
|