1 | ## Script (Python) "hall_delete" |
---|
2 | ##bind container=container |
---|
3 | ##bind context=context |
---|
4 | ##bind namespace= |
---|
5 | ##bind script=script |
---|
6 | ##bind subpath=traverse_subpath |
---|
7 | ##parameters=ids=[], REQUEST=None |
---|
8 | ##title= |
---|
9 | ## |
---|
10 | # $Id: hall_delete.py 2013 2007-07-12 16:12:23Z henrik $ |
---|
11 | """ |
---|
12 | FIXME: add docstring. |
---|
13 | """ |
---|
14 | |
---|
15 | import logging |
---|
16 | logger = logging.getLogger('Skins.hall_delete') |
---|
17 | member_id = str(context.portal_membership.getAuthenticatedMember()) |
---|
18 | |
---|
19 | from Products.CMFCore.utils import getToolByName |
---|
20 | here = context |
---|
21 | |
---|
22 | ti = getToolByName(here, 'portal_types').getTypeInfo(here.portal_type) |
---|
23 | meth_id = ti.queryMethodID('view', 'folder_contents') |
---|
24 | ret_url = here.absolute_url() + '/' + meth_id |
---|
25 | pa = context.portal_accommodation |
---|
26 | |
---|
27 | if ids: |
---|
28 | halls = [] |
---|
29 | for id in ids: |
---|
30 | # XXX has to be called from here since the workflow doesn't handle the |
---|
31 | # deletion yet |
---|
32 | halls.append(id) |
---|
33 | ob = getattr(here, id) |
---|
34 | from Products.CPSCore.EventServiceTool import getPublicEventService |
---|
35 | evtool = getPublicEventService(here) |
---|
36 | evtool.notifyEvent('workflow_delete', ob, {}) |
---|
37 | beds = pa(hall=id) |
---|
38 | urls = [] |
---|
39 | for bed in beds: |
---|
40 | urls.append(bed.bed) |
---|
41 | for url in urls: |
---|
42 | pa.deleteRecord(url) |
---|
43 | here.manage_delObjects(ids) |
---|
44 | message = 'portal_status_message=hall(s) %s with %s beds deleted' % (" ".join(halls),len(urls)) |
---|
45 | logger.info('%s deletes hall(s) %s with %s beds' % (member_id," ".join(halls),len(urls))) |
---|
46 | else: |
---|
47 | message = 'portal_status_message=psm_select_at_least_one_document' |
---|
48 | |
---|
49 | if REQUEST is not None: |
---|
50 | return REQUEST.RESPONSE.redirect(ret_url + '?' + message) |
---|