source: main/waeup.sirp/trunk/src/waeup/sirp/hostels/interfaces.py @ 6975

Last change on this file since 6975 was 6975, checked in by Henrik Bettermann, 14 years ago

Use List field for 'reserved' attribute and fill or remove list items when reserving or releasing a bed. The 'reserved' field should be omitted in the manage form. When clearing a hostel the reserved bed configuration remains and can be used when refilling the hostel in the following session.

  • Property svn:keywords set to Id
File size: 4.0 KB
Line 
1##
2## interfaces.py
3from zope.interface import Attribute, invariant, Invalid
4from zope import schema
5from waeup.sirp.interfaces import IWAeUPObject
6from waeup.sirp.hostels.vocabularies import (
7    bed_letters, blocks, special_handling)
8
9class IHostelsContainer(IWAeUPObject):
10    """A container for all kind of hostel objects.
11
12    """
13
14class IHostel(IWAeUPObject):
15    """A base representation of hostels.
16
17    """
18
19    def loggerInfo(ob_class, comment):
20        """Adds an INFO message to the log file
21        """
22
23    def updateBeds():
24        """Fill hostel with beds or update beds.
25        """
26
27    hostel_id = schema.TextLine(
28        title = u'Hostel Id',
29        readonly = True,
30        )
31
32    sort_id = schema.Int(
33        title = u'Sort Id',
34        required = True,
35        default = 10,
36        )
37
38    hostel_name = schema.TextLine(
39        title = u'Hall Name',
40        required = True,
41        default = u'Hall 1',
42        )
43
44    floors_per_block = schema.Int(
45        title = u'Floors per Block',
46        required = True,
47        default = 1,
48        )
49
50    rooms_per_floor = schema.Int(
51        title = u'Rooms per Floor',
52        required = True,
53        default = 2,
54        )
55
56    reserved = schema.List(
57        title = u'Reserved Beds',
58        value_type = schema.TextLine(
59            title = u'Bed',
60            default = u'',
61            required = False,
62        ),
63        required = True,
64        readonly = False,
65        default = [],
66        )
67
68    blocks_for_female = schema.List(
69        title = u'Blocks for Female Students',
70        value_type = schema.Choice(
71            vocabulary = blocks
72            ),
73        )
74
75    blocks_for_male = schema.List(
76        title = u'Blocks for Male Students',
77        value_type = schema.Choice(
78            vocabulary = blocks
79            ),
80        )
81
82    beds_for_fresh = schema.List(
83        title = u'Beds for Fresh Students',
84        value_type = schema.Choice(
85            vocabulary = bed_letters
86            ),
87        )
88
89    beds_for_returning = schema.List(
90        title = u'Beds for Returning Students',
91        value_type = schema.Choice(
92            vocabulary = bed_letters
93            ),
94        )
95
96    beds_for_final = schema.List(
97        title = u'Beds for Final Year Students',
98        value_type = schema.Choice(
99            vocabulary = bed_letters
100            ),
101        )
102
103    beds_for_all = schema.List(
104        title = u'Beds without category',
105        value_type = schema.Choice(
106            vocabulary = bed_letters
107            ),
108        )
109
110    special_handling = schema.Choice(
111        title = u'Special Handling',
112        vocabulary = special_handling,
113        required = True,
114        default = u'regular',
115        )
116
117    @invariant
118    def blocksOverlap(hostel):
119        bfe = hostel.blocks_for_female
120        bma = hostel.blocks_for_male
121        if set(bfe).intersection(set(bma)):
122            raise Invalid('Female and male blocks overlap.')
123
124    @invariant
125    def bedsOverlap(hostel):
126        bfr = hostel.beds_for_fresh
127        bre = hostel.beds_for_returning
128        bfi = hostel.beds_for_final
129        if (set(bfr).intersection(set(bre)) or
130            set(bfr).intersection(set(bfi)) or
131            set(bre).intersection(set(bfi))):
132            raise Invalid('Bed categories overlap.')
133
134class IBed(IWAeUPObject):
135    """A base representation of beds.
136
137    """
138
139    def loggerInfo(ob_class, comment):
140        """Adds an INFO message to the log file
141        """
142
143    def getBedCoordinates():
144        """Determine the coordinates from bed_id.
145        """
146
147    def switchReservation():
148        """Reserves bed or relases reserved bed respectively.
149        """
150
151    bed_id = schema.TextLine(
152        title = u'Bed Id',
153        required = True,
154        default = u'',
155        )
156
157    bed_type = schema.TextLine(
158        title = u'Bed Type',
159        required = True,
160        default = u'',
161        )
162
163    bed_number = schema.Int(
164        title = u'Bed Number',
165        required = True,
166        )
167
168    owner = schema.TextLine(
169        title = u'Owner (Student)',
170        required = True,
171        default = u'',
172        )
Note: See TracBrowser for help on using the repository browser.