1 | ## $Id: interfaces.py 9496 2012-11-01 08:35:49Z 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 | payments_folder = context.student['payments'] |
---|
40 | payments = [(p.p_session, p.p_category, p.p_state) |
---|
41 | for p in payments_folder.values()] |
---|
42 | courses = sorted(list(catalog.searchResults( |
---|
43 | code=(None, None))),key=lambda value: value.code) |
---|
44 | if (context.student.current_session, 'schoolfee_2', 'paid') in payments: |
---|
45 | pass |
---|
46 | else: |
---|
47 | courseslist = list(courses) |
---|
48 | for course in courseslist: |
---|
49 | if course.semester == 2: |
---|
50 | courses.remove(course) |
---|
51 | return courses |
---|
52 | |
---|
53 | def getToken(self, context, value): |
---|
54 | return value.code |
---|
55 | |
---|
56 | def getTitle(self, context, value): |
---|
57 | return "%s - %s (%d)" % ( |
---|
58 | value.code, value.title[:64], value.semester) |
---|
59 | |
---|
60 | class ICustomStudentBase(INigeriaStudentBase): |
---|
61 | """Representation of student base data. |
---|
62 | |
---|
63 | """ |
---|
64 | |
---|
65 | class ICustomStudentPersonal(INigeriaStudentPersonal): |
---|
66 | """Student personal data. |
---|
67 | |
---|
68 | """ |
---|
69 | |
---|
70 | class ICustomUGStudentClearance(INigeriaUGStudentClearance): |
---|
71 | """Representation of ug student clearance data. |
---|
72 | |
---|
73 | """ |
---|
74 | |
---|
75 | class ICustomPGStudentClearance(INigeriaPGStudentClearance): |
---|
76 | """Representation of pg student clearance data. |
---|
77 | |
---|
78 | """ |
---|
79 | |
---|
80 | |
---|
81 | class ICustomStudent(ICustomStudentBase,ICustomUGStudentClearance, |
---|
82 | ICustomPGStudentClearance,ICustomStudentPersonal): |
---|
83 | """Representation of a student. |
---|
84 | |
---|
85 | """ |
---|
86 | |
---|
87 | class ICustomStudentStudyCourse(INigeriaStudentStudyCourse): |
---|
88 | """A container for student study levels. |
---|
89 | |
---|
90 | """ |
---|
91 | |
---|
92 | class ICustomStudentStudyLevel(INigeriaStudentStudyLevel): |
---|
93 | """A container for course tickets. |
---|
94 | |
---|
95 | """ |
---|
96 | |
---|
97 | class ICustomStudentOnlinePayment(ICustomOnlinePayment): |
---|
98 | """A student payment via payment gateways. |
---|
99 | |
---|
100 | This Interface does not inherit from IStudentOnlinePayment. |
---|
101 | Thus all fields from IStudentOnlinePayment have to be repeated here. |
---|
102 | """ |
---|
103 | |
---|
104 | p_current = schema.Bool( |
---|
105 | title = _(u'Current Session Payment'), |
---|
106 | default = True, |
---|
107 | required = False, |
---|
108 | ) |
---|
109 | |
---|
110 | p_level = schema.Int( |
---|
111 | title = _(u'Payment Level'), |
---|
112 | required = False, |
---|
113 | readonly = True, |
---|
114 | ) |
---|
115 | |
---|
116 | ICustomStudentOnlinePayment['p_level'].order = ICustomStudentOnlinePayment[ |
---|
117 | 'p_session'].order |
---|
118 | |
---|
119 | class ICustomCourseTicket(INigeriaCourseTicket): |
---|
120 | """A course ticket. |
---|
121 | |
---|
122 | """ |
---|
123 | |
---|
124 | class ICustomCourseTicketAdd(IKofaObject): |
---|
125 | """An interface for adding course tickets. |
---|
126 | |
---|
127 | """ |
---|
128 | course = schema.Choice( |
---|
129 | title = _(u'Course'), |
---|
130 | source = CourseSource(), |
---|
131 | readonly = False, |
---|
132 | ) |
---|
133 | |
---|
134 | class ICustomStudentUpdateByRegNo(INigeriaStudentUpdateByRegNo): |
---|
135 | """Representation of a student. Skip regular reg_number validation. |
---|
136 | |
---|
137 | """ |
---|
138 | |
---|
139 | class ICustomStudentUpdateByMatricNo(INigeriaStudentUpdateByMatricNo): |
---|
140 | """Representation of a student. Skip regular matric_number validation. |
---|
141 | |
---|
142 | """ |
---|