source: WAeUP_SRP/trunk/Accommodation.py @ 405

Last change on this file since 405 was 404, checked in by joachim, 18 years ago

accommodation startet

  • Property svn:keywords set to Id
File size: 2.6 KB
Line 
1#-*- mode: python; mode: fold -*-
2from Globals import InitializeClass
3from AccessControl import ClassSecurityInfo
4
5from Products.CMFCore.utils import UniqueObject, getToolByName
6from Products.CMFCore.permissions import View
7from Products.CMFCore.permissions import ModifyPortalContent
8from Products.CPSCore.CPSBase import CPSBase_adder, CPSBaseFolder
9#from Products.CPSCore.CPSBase import CPSBaseDocument as BaseDocument
10from Products.CPSDocument.CPSDocument import CPSDocument
11from Products.CPSCore.CPSBase import CPSBaseBTreeFolder as BaseBTreeFolder
12from Products.WAeUP_SRP.WAeUPTables import AccommodationTable
13
14class AccoFolder(CPSDocument): ###(
15    """
16    WAeUP AccoFolder containing Accommodation halls
17    """
18    meta_type = 'AccoFolder'
19    portal_type = meta_type
20    security = ClassSecurityInfo()
21   
22    security.declareProtected(ModifyPortalContent,"generateFreeBedsList") ###(
23    def generateFreeBedsList(self):
24        """
25        generate the free Bedslist.
26        """
27        freelist = AccommodationTable()
28        l = self.portal_catalog({'meta_type': "Accommodation"})
29        halls = []
30        for h in l:
31            halls.append(h.getObject())
32        for hall in halls:
33            h = hall.getContent()
34            for block in range(1,int(h.nr_of_blocks)):
35                for floor in range(1,int(h.nr_of_floors)):
36                    for room in range(1,int(h.rooms_per_floor)):
37                        for bed in 'ABCDEFGH'[:int(h.beds_per_room)]:
38                            room_nr = floor*100 + room
39                            freelist.addRecord(bed = '%s_%d_%s' % (h.getId(),room_nr,bed),
40                                               bed_type = "test")
41
42###)
43
44InitializeClass(AccoFolder)
45
46def addAccoFolder(container, id, REQUEST=None, **kw):
47    """Add a AccoFolder."""
48    ob = AccoFolder(id, **kw)
49    return CPSBase_adder(container, ob, REQUEST=REQUEST)
50###)
51
52class Accommodation(CPSDocument): ###(
53    """
54    WAeUP Accommodation containing Departments
55    """
56    meta_type = 'Accommodation'
57    portal_type = meta_type
58    security = ClassSecurityInfo()
59   
60    security.declareProtected(View,"Title") ###(
61    def Title(self):
62        """compose title"""
63        content = self.getContent()
64        heading = getattr(content,'heading',None)
65        if heading is None:
66            return self.title
67        return heading
68
69###)
70
71       
72                           
73               
74InitializeClass(Accommodation)
75
76def addAccommodation(container, id, REQUEST=None, **kw):
77    """Add a Accommodation."""
78    ob = Accommodation(id, **kw)
79    return CPSBase_adder(container, ob, REQUEST=REQUEST)
80###)
Note: See TracBrowser for help on using the repository browser.