[15644] | 1 | ## $Id: interfaces.py 17689 2024-01-31 11:42:09Z henrik $ |
---|
| 2 | ## |
---|
| 3 | ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann |
---|
| 4 | ## This program is free software; you can redistribute it and/or modify |
---|
| 5 | ## it under the terms of the GNU General Public License as published by |
---|
| 6 | ## the Free Software Foundation; either version 2 of the License, or |
---|
| 7 | ## (at your option) any later version. |
---|
| 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 02111-1307 USA |
---|
| 17 | ## |
---|
| 18 | from grok import getSite |
---|
| 19 | from datetime import datetime |
---|
| 20 | from zope.component import getUtility |
---|
| 21 | from zope.catalog.interfaces import ICatalog |
---|
| 22 | from zope.interface import invariant, Invalid, Attribute, Interface |
---|
| 23 | from zope import schema |
---|
| 24 | from waeup.kofa.interfaces import SimpleKofaVocabulary |
---|
| 25 | from waeup.kofa.hostels.interfaces import IHostel, IBed |
---|
| 26 | |
---|
[17689] | 27 | from kofacustom.udss.interfaces import MessageFactory as _ |
---|
[15644] | 28 | |
---|
| 29 | blocks = SimpleKofaVocabulary( |
---|
| 30 | (_('Block 1'),'1'), |
---|
| 31 | (_('Block 2'),'2'), |
---|
| 32 | (_('Block 3'),'3'), |
---|
| 33 | (_('Block 4'),'4'), |
---|
| 34 | (_('Block 5'),'5'), |
---|
| 35 | (_('Block 6'),'6'), |
---|
| 36 | (_('Block 7'),'7'), |
---|
| 37 | (_('Block 8'),'8'), |
---|
| 38 | (_('Block 9'),'9'), |
---|
| 39 | (_('Block 10'),'10'), |
---|
| 40 | (_('Block 11'),'11'), |
---|
| 41 | (_('Block 12'),'12'), |
---|
| 42 | (_('Block 13'),'13'), |
---|
| 43 | (_('Block 14'),'14'), |
---|
| 44 | (_('Block 15'),'15'), |
---|
| 45 | (_('Block 16'),'16'), |
---|
| 46 | (_('Block 17'),'17'), |
---|
| 47 | (_('Block 18'),'18'), |
---|
| 48 | (_('Block 19'),'19'), |
---|
| 49 | ) |
---|
| 50 | |
---|
| 51 | class ICustomHostel(IHostel): |
---|
| 52 | """Representation of a hostel. |
---|
| 53 | """ |
---|
| 54 | |
---|
| 55 | floors_per_block = schema.Int( |
---|
| 56 | title = _(u'Flats per Block'), |
---|
| 57 | required = True, |
---|
| 58 | default = 1, |
---|
| 59 | ) |
---|
| 60 | |
---|
| 61 | rooms_per_floor = schema.Int( |
---|
| 62 | title = _(u'Rooms per Flat'), |
---|
| 63 | required = True, |
---|
| 64 | default = 2, |
---|
| 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 | defaultFactory=list, |
---|
| 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 | defaultFactory=list, |
---|
| 81 | ) |
---|
| 82 | |
---|
| 83 | ICustomHostel['floors_per_block'].order = IHostel[ |
---|
| 84 | 'floors_per_block'].order |
---|
| 85 | ICustomHostel['rooms_per_floor'].order = IHostel[ |
---|
| 86 | 'rooms_per_floor'].order |
---|
| 87 | ICustomHostel['blocks_for_female'].order = IHostel[ |
---|
| 88 | 'blocks_for_female'].order |
---|
| 89 | ICustomHostel['blocks_for_male'].order = IHostel[ |
---|
| 90 | 'blocks_for_male'].order |
---|
| 91 | |
---|
| 92 | class ICustomBed(IBed): |
---|
| 93 | """Representation of a bed. |
---|
| 94 | """ |
---|
| 95 | |
---|