[7505] | 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 | ## |
---|
[8867] | 18 | |
---|
[7505] | 19 | from zope import schema |
---|
[9496] | 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 |
---|
[8867] | 24 | from kofacustom.nigeria.students.interfaces import ( |
---|
| 25 | INigeriaStudentBase, INigeriaUGStudentClearance, INigeriaPGStudentClearance, |
---|
| 26 | INigeriaStudentPersonal, INigeriaStudentStudyLevel, |
---|
| 27 | INigeriaStudentStudyCourse, INigeriaCourseTicket, |
---|
| 28 | INigeriaStudentUpdateByRegNo, INigeriaStudentUpdateByMatricNo, |
---|
[7505] | 29 | ) |
---|
[8867] | 30 | from waeup.aaue.payments.interfaces import ICustomOnlinePayment |
---|
[8444] | 31 | from waeup.aaue.interfaces import MessageFactory as _ |
---|
[7505] | 32 | |
---|
[9496] | 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 | |
---|
[8867] | 60 | class ICustomStudentBase(INigeriaStudentBase): |
---|
[7618] | 61 | """Representation of student base data. |
---|
[7505] | 62 | |
---|
| 63 | """ |
---|
[7618] | 64 | |
---|
[8867] | 65 | class ICustomStudentPersonal(INigeriaStudentPersonal): |
---|
[7618] | 66 | """Student personal data. |
---|
| 67 | |
---|
| 68 | """ |
---|
| 69 | |
---|
[8867] | 70 | class ICustomUGStudentClearance(INigeriaUGStudentClearance): |
---|
[7995] | 71 | """Representation of ug student clearance data. |
---|
[7505] | 72 | |
---|
| 73 | """ |
---|
| 74 | |
---|
[8867] | 75 | class ICustomPGStudentClearance(INigeriaPGStudentClearance): |
---|
[7995] | 76 | """Representation of pg student clearance data. |
---|
[7505] | 77 | |
---|
| 78 | """ |
---|
| 79 | |
---|
[8101] | 80 | |
---|
[8204] | 81 | class ICustomStudent(ICustomStudentBase,ICustomUGStudentClearance, |
---|
| 82 | ICustomPGStudentClearance,ICustomStudentPersonal): |
---|
[7995] | 83 | """Representation of a student. |
---|
[7505] | 84 | |
---|
| 85 | """ |
---|
[8247] | 86 | |
---|
[8867] | 87 | class ICustomStudentStudyCourse(INigeriaStudentStudyCourse): |
---|
[8326] | 88 | """A container for student study levels. |
---|
| 89 | |
---|
| 90 | """ |
---|
| 91 | |
---|
[8867] | 92 | class ICustomStudentStudyLevel(INigeriaStudentStudyLevel): |
---|
[8326] | 93 | """A container for course tickets. |
---|
| 94 | |
---|
| 95 | """ |
---|
| 96 | |
---|
[8247] | 97 | class ICustomStudentOnlinePayment(ICustomOnlinePayment): |
---|
| 98 | """A student payment via payment gateways. |
---|
| 99 | |
---|
[8270] | 100 | This Interface does not inherit from IStudentOnlinePayment. |
---|
| 101 | Thus all fields from IStudentOnlinePayment have to be repeated here. |
---|
| 102 | """ |
---|
| 103 | |
---|
[9154] | 104 | p_current = schema.Bool( |
---|
| 105 | title = _(u'Current Session Payment'), |
---|
| 106 | default = True, |
---|
| 107 | required = False, |
---|
| 108 | ) |
---|
| 109 | |
---|
[8270] | 110 | p_level = schema.Int( |
---|
| 111 | title = _(u'Payment Level'), |
---|
| 112 | required = False, |
---|
| 113 | readonly = True, |
---|
| 114 | ) |
---|
[8430] | 115 | |
---|
[8270] | 116 | ICustomStudentOnlinePayment['p_level'].order = ICustomStudentOnlinePayment[ |
---|
[8326] | 117 | 'p_session'].order |
---|
| 118 | |
---|
[8867] | 119 | class ICustomCourseTicket(INigeriaCourseTicket): |
---|
[8326] | 120 | """A course ticket. |
---|
| 121 | |
---|
[8583] | 122 | """ |
---|
| 123 | |
---|
[9496] | 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 | |
---|
[8867] | 134 | class ICustomStudentUpdateByRegNo(INigeriaStudentUpdateByRegNo): |
---|
[8583] | 135 | """Representation of a student. Skip regular reg_number validation. |
---|
| 136 | |
---|
| 137 | """ |
---|
| 138 | |
---|
[8867] | 139 | class ICustomStudentUpdateByMatricNo(INigeriaStudentUpdateByMatricNo): |
---|
[8583] | 140 | """Representation of a student. Skip regular matric_number validation. |
---|
| 141 | |
---|
[8867] | 142 | """ |
---|