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

Last change on this file since 6980 was 6976, checked in by Henrik Bettermann, 13 years ago

Consider bed_reserved attribute when filling up an (old) hostel.

  • 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    beds_reserved = schema.List(
57        title = u'Reserved Beds',
58        value_type = schema.TextLine(
59            default = u'',
60            required = False,
61        ),
62        required = True,
63        readonly = False,
64        default = [],
65        )
66
67    blocks_for_female = schema.List(
68        title = u'Blocks for Female Students',
69        value_type = schema.Choice(
70            vocabulary = blocks
71            ),
72        )
73
74    blocks_for_male = schema.List(
75        title = u'Blocks for Male Students',
76        value_type = schema.Choice(
77            vocabulary = blocks
78            ),
79        )
80
81    beds_for_fresh = schema.List(
82        title = u'Beds for Fresh Students',
83        value_type = schema.Choice(
84            vocabulary = bed_letters
85            ),
86        )
87
88    beds_for_returning = schema.List(
89        title = u'Beds for Returning Students',
90        value_type = schema.Choice(
91            vocabulary = bed_letters
92            ),
93        )
94
95    beds_for_final = schema.List(
96        title = u'Beds for Final Year Students',
97        value_type = schema.Choice(
98            vocabulary = bed_letters
99            ),
100        )
101
102    beds_for_all = schema.List(
103        title = u'Beds without category',
104        value_type = schema.Choice(
105            vocabulary = bed_letters
106            ),
107        )
108
109    special_handling = schema.Choice(
110        title = u'Special Handling',
111        vocabulary = special_handling,
112        required = True,
113        default = u'regular',
114        )
115
116    @invariant
117    def blocksOverlap(hostel):
118        bfe = hostel.blocks_for_female
119        bma = hostel.blocks_for_male
120        if set(bfe).intersection(set(bma)):
121            raise Invalid('Female and male blocks overlap.')
122
123    @invariant
124    def bedsOverlap(hostel):
125        bfr = hostel.beds_for_fresh
126        bre = hostel.beds_for_returning
127        bfi = hostel.beds_for_final
128        if (set(bfr).intersection(set(bre)) or
129            set(bfr).intersection(set(bfi)) or
130            set(bre).intersection(set(bfi))):
131            raise Invalid('Bed categories overlap.')
132
133class IBed(IWAeUPObject):
134    """A base representation of beds.
135
136    """
137
138    def loggerInfo(ob_class, comment):
139        """Adds an INFO message to the log file
140        """
141
142    def getBedCoordinates():
143        """Determine the coordinates from bed_id.
144        """
145
146    def switchReservation():
147        """Reserves bed or relases reserved bed respectively.
148        """
149
150    bed_id = schema.TextLine(
151        title = u'Bed Id',
152        required = True,
153        default = u'',
154        )
155
156    bed_type = schema.TextLine(
157        title = u'Bed Type',
158        required = True,
159        default = u'',
160        )
161
162    bed_number = schema.Int(
163        title = u'Bed Number',
164        required = True,
165        )
166
167    owner = schema.TextLine(
168        title = u'Owner (Student)',
169        required = True,
170        default = u'',
171        )
Note: See TracBrowser for help on using the repository browser.