source: WAeUP_SRP/trunk/WAeUPTool.py @ 861

Last change on this file since 861 was 828, checked in by joachim, 18 years ago

reenabled waeup_tool,
reserve accommodation fixed

  • Property svn:keywords set to Id
File size: 2.9 KB
Line 
1#-*- mode: python; mode: fold -*-
2# (C) Copyright 2005 The WAeUP group  <http://www.waeup.org>
3# Author: Joachim Schmitz (js@aixtraware.de)
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 2 as published
7# by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software
16# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17# 02111-1307, USA.
18#
19# $Id: WAeUPTool.py 828 2006-11-10 15:26:31Z joachim $
20"""The WAeUPTool.
21
22$Id: WAeUPTool.py 828 2006-11-10 15:26:31Z joachim $
23"""
24
25from AccessControl import ClassSecurityInfo
26from Acquisition import aq_inner
27from Acquisition import aq_parent
28from Globals import DTMLFile
29from Globals import InitializeClass
30from OFS.SimpleItem import SimpleItem
31
32from Products.CMFCore.ActionProviderBase import ActionProviderBase
33from Products.CMFCore.permissions import View
34from Products.ZCatalog.ZCatalog import ZCatalog
35from Products.CMFCore.permissions import ModifyPortalContent
36from Products.CMFCore.utils import UniqueObject
37
38class WAeUPTool(UniqueObject, SimpleItem, ActionProviderBase):
39    """WAeUP tool"""
40
41    id = 'waeup_tool'
42    meta_type = 'WAeUP Tool'
43    _actions = ()
44
45    security = ClassSecurityInfo()
46    security.declareObjectProtected(View)
47
48    manage_options = ( ActionProviderBase.manage_options
49                     + SimpleItem.manage_options
50                     )
51
52##    security.declarePublic('getHallTitle')
53##    def getHallTitle(self,hall):
54##        """get the Hall Title"""
55##        res = ZCatalog.searchResults(self.portal_catalog,portal_type="AccoHall",id=hall)
56##        if res and len(res) == 1:
57##            return res[0].Title
58##        return hall
59
60    security.declarePublic('getAccommodationInfo')
61    def getAccommodationInfo(self,bed):
62        """return Accommodation Info"""
63        info = {}
64        hall,block,room,letter = bed.split('_')
65        res = ZCatalog.searchResults(self.portal_catalog,portal_type="AccoHall",id=hall)
66        if res and len(res) == 1:
67            hall_brain = res[0]
68            hall_doc = hall_brain.getObject().getContent()
69        else:
70            return info
71        info['hall_title'] = hall_brain.Title
72        info['maintenance_code'] = hall_doc.maintenance_code
73        res = ZCatalog.searchResults(self.portal_catalog,portal_type="ScratchCardBatch")
74        batch_doc = None
75        for brain in res:
76            if brain.id.startswith(info['maintenance_code']):
77                batch_doc = brain.getObject().getContent()
78                break
79        if batch_doc is None:
80            info['maintenance_fee'] = None
81        else:
82            info['maintenance_fee'] = batch_doc.cost
83        return info
84
85InitializeClass(WAeUPTool)
Note: See TracBrowser for help on using the repository browser.