1 | ## $Id: interfaces.py 9537 2012-11-05 17:47:30Z 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 | |
---|
19 | from zope import schema |
---|
20 | from zc.sourcefactory.contextual import BasicContextualSourceFactory |
---|
21 | from zope.catalog.interfaces import ICatalog |
---|
22 | from zope.component import getUtility |
---|
23 | from waeup.kofa.interfaces import IKofaObject |
---|
24 | from kofacustom.nigeria.students.interfaces import ( |
---|
25 | INigeriaStudentBase, INigeriaUGStudentClearance, INigeriaPGStudentClearance, |
---|
26 | INigeriaStudentPersonal, INigeriaStudentStudyLevel, |
---|
27 | INigeriaStudentStudyCourse, INigeriaCourseTicket, |
---|
28 | INigeriaStudentUpdateByRegNo, INigeriaStudentUpdateByMatricNo, |
---|
29 | ) |
---|
30 | from waeup.aaue.payments.interfaces import ICustomOnlinePayment |
---|
31 | from waeup.aaue.interfaces import MessageFactory as _ |
---|
32 | |
---|
33 | class 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 | |
---|
58 | class ICustomStudentBase(INigeriaStudentBase): |
---|
59 | """Representation of student base data. |
---|
60 | |
---|
61 | """ |
---|
62 | |
---|
63 | class ICustomStudentPersonal(INigeriaStudentPersonal): |
---|
64 | """Student personal data. |
---|
65 | |
---|
66 | """ |
---|
67 | |
---|
68 | class ICustomUGStudentClearance(INigeriaUGStudentClearance): |
---|
69 | """Representation of ug student clearance data. |
---|
70 | |
---|
71 | """ |
---|
72 | |
---|
73 | class ICustomPGStudentClearance(INigeriaPGStudentClearance): |
---|
74 | """Representation of pg student clearance data. |
---|
75 | |
---|
76 | """ |
---|
77 | |
---|
78 | |
---|
79 | class ICustomStudent(ICustomStudentBase,ICustomUGStudentClearance, |
---|
80 | ICustomPGStudentClearance,ICustomStudentPersonal): |
---|
81 | """Representation of a student. |
---|
82 | |
---|
83 | """ |
---|
84 | |
---|
85 | class ICustomStudentStudyCourse(INigeriaStudentStudyCourse): |
---|
86 | """A container for student study levels. |
---|
87 | |
---|
88 | """ |
---|
89 | |
---|
90 | class ICustomStudentStudyLevel(INigeriaStudentStudyLevel): |
---|
91 | """A container for course tickets. |
---|
92 | |
---|
93 | """ |
---|
94 | |
---|
95 | class 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 | ) |
---|
112 | |
---|
113 | ICustomStudentOnlinePayment['p_level'].order = ICustomStudentOnlinePayment[ |
---|
114 | 'p_session'].order |
---|
115 | |
---|
116 | class ICustomCourseTicket(INigeriaCourseTicket): |
---|
117 | """A course ticket. |
---|
118 | |
---|
119 | """ |
---|
120 | |
---|
121 | class ICustomCourseTicketAdd(IKofaObject): |
---|
122 | """An interface for adding course tickets. |
---|
123 | |
---|
124 | """ |
---|
125 | course = schema.Choice( |
---|
126 | title = _(u'Course'), |
---|
127 | source = CourseSource(), |
---|
128 | readonly = False, |
---|
129 | ) |
---|
130 | |
---|
131 | class ICustomStudentUpdateByRegNo(INigeriaStudentUpdateByRegNo): |
---|
132 | """Representation of a student. Skip regular reg_number validation. |
---|
133 | |
---|
134 | """ |
---|
135 | |
---|
136 | class ICustomStudentUpdateByMatricNo(INigeriaStudentUpdateByMatricNo): |
---|
137 | """Representation of a student. Skip regular matric_number validation. |
---|
138 | |
---|
139 | """ |
---|