source: main/waeup.sirp/trunk/src/waeup/sirp/students/accommodation.py @ 6994

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

Remove maintenance fee attributes. We don't need them in bed tickets.

Add BedTicketDisplayFormPage?.

getPaymentDetails and getAccommodationDetails: Return dictionary instead of tuple.

Callback now provides a HOS pin when applied to IStudentOnlinePayment instances.

  • Property svn:keywords set to Id
File size: 2.9 KB
Line 
1## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
2## This program is free software; you can redistribute it and/or modify
3## it under the terms of the GNU General Public License as published by
4## the Free Software Foundation; either version 2 of the License, or
5## (at your option) any later version.
6##
7## This program is distributed in the hope that it will be useful,
8## but WITHOUT ANY WARRANTY; without even the implied warranty of
9## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10## GNU General Public License for more details.
11##
12## You should have received a copy of the GNU General Public License
13## along with this program; if not, write to the Free Software
14## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15##
16"""
17Container which contains the (student) accommodation objects.
18"""
19from datetime import datetime
20import grok
21from grok import index
22from zope.component.interfaces import IFactory
23from waeup.sirp.interfaces import academic_sessions_vocab
24from waeup.sirp.students.interfaces import (
25    IStudentAccommodation, IStudentNavigation, IBedTicket)
26from waeup.sirp.utils.helpers import attrs_to_fields
27
28class StudentAccommodation(grok.Container):
29    """This is a container for accommodation objects.
30    """
31    grok.implements(IStudentAccommodation, IStudentNavigation)
32    grok.provides(IStudentAccommodation)
33
34    def __init__(self):
35        super(StudentAccommodation, self).__init__()
36        return
37
38    def addBedTicket(self, bedticket):
39        """Add a bed ticket object.
40        """
41        if not IBedTicket.providedBy(bedticket):
42            raise TypeError(
43                'StudentAccommodation containers contain only IBedTicket instances')
44        self[bedticket.ticket_id] = bedticket
45        return
46
47    def getStudent(self):
48        return self.__parent__
49
50StudentAccommodation = attrs_to_fields(StudentAccommodation)
51
52class BedTicket(grok.Model):
53    """This is a bed ticket which shows that the student has booked a bed
54    and paid the maintenance fee.
55    """
56    grok.implements(IBedTicket, IStudentNavigation)
57    grok.provides(IBedTicket)
58
59    def __init__(self):
60        super(BedTicket, self).__init__()
61        self.booking_date = datetime.now()
62        return
63
64    def getStudent(self):
65        return self.__parent__.__parent__
66
67    def getSessionString(self):
68        return academic_sessions_vocab.getTerm(
69            self.booking_session).title
70
71BedTicket = attrs_to_fields(BedTicket)
72
73# Bed tickets must be importable. So we might need a factory.
74class BedTicketFactory(grok.GlobalUtility):
75    """A factory for bed tickets.
76    """
77    grok.implements(IFactory)
78    grok.name(u'waeup.BedTicket')
79    title = u"Create a new bed ticket.",
80    description = u"This factory instantiates new bed ticket instances."
81
82    def __call__(self, *args, **kw):
83        return BedTicket()
84
85    def getInterfaces(self):
86        return implementedBy(BedTicket)
Note: See TracBrowser for help on using the repository browser.