source: main/waeup.aaue/trunk/src/waeup/aaue/students/interfaces.py @ 9504

Last change on this file since 9504 was 9502, checked in by Henrik Bettermann, 12 years ago

Customize addCertCourseTickets. Add ticket only if student has paid for the course.semester. Tests will follow.

  • Property svn:keywords set to Id
File size: 4.3 KB
Line 
1## $Id: interfaces.py 9502 2012-11-02 06:13:11Z henrik $
2##
3## Copyright (C) 2012 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
19from zope import schema
20from zc.sourcefactory.contextual import BasicContextualSourceFactory
21from zope.catalog.interfaces import ICatalog
22from zope.component import getUtility
23from waeup.kofa.interfaces import IKofaObject
24from kofacustom.nigeria.students.interfaces import (
25    INigeriaStudentBase, INigeriaUGStudentClearance, INigeriaPGStudentClearance,
26    INigeriaStudentPersonal, INigeriaStudentStudyLevel,
27    INigeriaStudentStudyCourse, INigeriaCourseTicket,
28    INigeriaStudentUpdateByRegNo, INigeriaStudentUpdateByMatricNo,
29    )
30from waeup.aaue.payments.interfaces import ICustomOnlinePayment
31from waeup.aaue.interfaces import MessageFactory as _
32
33class CourseSource(BasicContextualSourceFactory):
34    """A course source delivers all courses inside the portal by looking
35       up a catalog.
36    """
37    def getValues(self, context):
38        catalog = getUtility(ICatalog, name='courses_catalog')
39        courses = sorted(list(catalog.searchResults(
40            code=(None, None))),key=lambda value: value.code)
41        payments = context.student.getPaymentTuples()
42        if (context.student.current_session, 'schoolfee_2', 'paid') in payments:
43            pass
44        else:
45            courseslist = list(courses)
46            for course in courseslist:
47                if course.semester == 2:
48                    courses.remove(course)
49        return courses
50
51    def getToken(self, context, value):
52        return value.code
53
54    def getTitle(self, context, value):
55        return "%s - %s (%d)" % (
56            value.code, value.title[:64], value.semester)
57
58class ICustomStudentBase(INigeriaStudentBase):
59    """Representation of student base data.
60
61    """
62
63class ICustomStudentPersonal(INigeriaStudentPersonal):
64    """Student personal data.
65
66    """
67
68class ICustomUGStudentClearance(INigeriaUGStudentClearance):
69    """Representation of ug student clearance data.
70
71    """
72
73class ICustomPGStudentClearance(INigeriaPGStudentClearance):
74    """Representation of pg student clearance data.
75
76    """
77
78
79class ICustomStudent(ICustomStudentBase,ICustomUGStudentClearance,
80    ICustomPGStudentClearance,ICustomStudentPersonal):
81    """Representation of a student.
82
83    """
84
85class ICustomStudentStudyCourse(INigeriaStudentStudyCourse):
86    """A container for student study levels.
87
88    """
89
90class ICustomStudentStudyLevel(INigeriaStudentStudyLevel):
91    """A container for course tickets.
92
93    """
94
95class ICustomStudentOnlinePayment(ICustomOnlinePayment):
96    """A student payment via payment gateways.
97
98    This Interface does not inherit from IStudentOnlinePayment.
99    Thus all fields from IStudentOnlinePayment have to be repeated here.
100    """
101
102    p_current = schema.Bool(
103        title = _(u'Current Session Payment'),
104        default = True,
105        required = False,
106        )
107
108    p_level = schema.Int(
109        title = _(u'Payment Level'),
110        required = False,
111        readonly = True,
112        )
113
114ICustomStudentOnlinePayment['p_level'].order = ICustomStudentOnlinePayment[
115    'p_session'].order
116
117class ICustomCourseTicket(INigeriaCourseTicket):
118    """A course ticket.
119
120    """
121
122class ICustomCourseTicketAdd(IKofaObject):
123    """An interface for adding course tickets.
124
125    """
126    course = schema.Choice(
127        title = _(u'Course'),
128        source = CourseSource(),
129        readonly = False,
130        )
131
132class ICustomStudentUpdateByRegNo(INigeriaStudentUpdateByRegNo):
133    """Representation of a student. Skip regular reg_number validation.
134
135    """
136
137class ICustomStudentUpdateByMatricNo(INigeriaStudentUpdateByMatricNo):
138    """Representation of a student. Skip regular matric_number validation.
139
140    """
Note: See TracBrowser for help on using the repository browser.