source: WAeUP_SRP/trunk/skins/waeup_accommodation/hall_delete.py @ 12407

Last change on this file since 12407 was 2013, checked in by Henrik Bettermann, 17 years ago

see ticket #102

  • Property svn:keywords set to Id
File size: 1.5 KB
Line 
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"""
12FIXME: add docstring.
13"""
14
15import logging
16logger = logging.getLogger('Skins.hall_delete')
17member_id = str(context.portal_membership.getAuthenticatedMember())
18
19from Products.CMFCore.utils import getToolByName
20here = context
21
22ti = getToolByName(here, 'portal_types').getTypeInfo(here.portal_type)
23meth_id = ti.queryMethodID('view', 'folder_contents')
24ret_url = here.absolute_url() + '/' + meth_id
25pa = context.portal_accommodation
26
27if 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)))
46else:
47    message = 'portal_status_message=psm_select_at_least_one_document'
48
49if REQUEST is not None:
50    return REQUEST.RESPONSE.redirect(ret_url + '?' + message)
Note: See TracBrowser for help on using the repository browser.