Last change
on this file since 1 was
1,
checked in by myroslav, 19 years ago
|
Building directory structure
|
-
Property svn:eol-style set to
native
|
File size:
985 bytes
|
Line | |
---|
1 | ## Script (Python) "deleteDiscussion" |
---|
2 | ##bind container=container |
---|
3 | ##bind context=context |
---|
4 | ##bind namespace= |
---|
5 | ##bind script=script |
---|
6 | ##bind subpath=traverse_subpath |
---|
7 | ##parameters=obj=None |
---|
8 | ##title=Delete discussion item |
---|
9 | ## |
---|
10 | |
---|
11 | from Products.qPloneComments.utils import manage_mails |
---|
12 | from Products.CMFPlone import MessageFactory |
---|
13 | qpcMF = MessageFactory('plonecomments') |
---|
14 | |
---|
15 | |
---|
16 | if obj is None: |
---|
17 | obj=context |
---|
18 | |
---|
19 | parent = obj.inReplyTo() |
---|
20 | if parent is not None: |
---|
21 | talkback = context.portal_discussion.getDiscussionFor(parent) |
---|
22 | else: |
---|
23 | talkback = parent = obj.aq_parent |
---|
24 | |
---|
25 | # remove the discussion item |
---|
26 | talkback.deleteReply( obj.getId() ) |
---|
27 | manage_mails(obj, context, 'deleting') |
---|
28 | |
---|
29 | # redirect to the object that is being discussed |
---|
30 | redirect_target = context.plone_utils.getDiscussionThread(talkback)[0] |
---|
31 | view = redirect_target.getTypeInfo().getActionById('view') |
---|
32 | |
---|
33 | context.plone_utils.addPortalMessage(qpcMF(u'Reply deleted.')) |
---|
34 | |
---|
35 | context.REQUEST['RESPONSE'].redirect( redirect_target.absolute_url() + '/%s' % view ) |
---|
Note: See
TracBrowser
for help on using the repository browser.