[7505] | 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 | ## |
---|
[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 | courses = sorted(list(catalog.searchResults( |
---|
| 40 | code=(None, None))),key=lambda value: value.code) |
---|
[9502] | 41 | payments = context.student.getPaymentTuples() |
---|
[9496] | 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 | |
---|
[8867] | 58 | class ICustomStudentBase(INigeriaStudentBase): |
---|
[7618] | 59 | """Representation of student base data. |
---|
[7505] | 60 | |
---|
| 61 | """ |
---|
[7618] | 62 | |
---|
[8867] | 63 | class ICustomStudentPersonal(INigeriaStudentPersonal): |
---|
[7618] | 64 | """Student personal data. |
---|
| 65 | |
---|
| 66 | """ |
---|
| 67 | |
---|
[8867] | 68 | class ICustomUGStudentClearance(INigeriaUGStudentClearance): |
---|
[7995] | 69 | """Representation of ug student clearance data. |
---|
[7505] | 70 | |
---|
| 71 | """ |
---|
| 72 | |
---|
[8867] | 73 | class ICustomPGStudentClearance(INigeriaPGStudentClearance): |
---|
[7995] | 74 | """Representation of pg student clearance data. |
---|
[7505] | 75 | |
---|
| 76 | """ |
---|
| 77 | |
---|
[8101] | 78 | |
---|
[8204] | 79 | class ICustomStudent(ICustomStudentBase,ICustomUGStudentClearance, |
---|
| 80 | ICustomPGStudentClearance,ICustomStudentPersonal): |
---|
[7995] | 81 | """Representation of a student. |
---|
[7505] | 82 | |
---|
| 83 | """ |
---|
[8247] | 84 | |
---|
[8867] | 85 | class ICustomStudentStudyCourse(INigeriaStudentStudyCourse): |
---|
[8326] | 86 | """A container for student study levels. |
---|
| 87 | |
---|
| 88 | """ |
---|
| 89 | |
---|
[8867] | 90 | class ICustomStudentStudyLevel(INigeriaStudentStudyLevel): |
---|
[8326] | 91 | """A container for course tickets. |
---|
| 92 | |
---|
| 93 | """ |
---|
| 94 | |
---|
[8247] | 95 | class ICustomStudentOnlinePayment(ICustomOnlinePayment): |
---|
| 96 | """A student payment via payment gateways. |
---|
| 97 | |
---|
[8270] | 98 | This Interface does not inherit from IStudentOnlinePayment. |
---|
| 99 | Thus all fields from IStudentOnlinePayment have to be repeated here. |
---|
| 100 | """ |
---|
| 101 | |
---|
[9154] | 102 | p_current = schema.Bool( |
---|
| 103 | title = _(u'Current Session Payment'), |
---|
| 104 | default = True, |
---|
| 105 | required = False, |
---|
| 106 | ) |
---|
| 107 | |
---|
[8270] | 108 | p_level = schema.Int( |
---|
| 109 | title = _(u'Payment Level'), |
---|
| 110 | required = False, |
---|
| 111 | ) |
---|
[8430] | 112 | |
---|
[8270] | 113 | ICustomStudentOnlinePayment['p_level'].order = ICustomStudentOnlinePayment[ |
---|
[8326] | 114 | 'p_session'].order |
---|
| 115 | |
---|
[8867] | 116 | class ICustomCourseTicket(INigeriaCourseTicket): |
---|
[8326] | 117 | """A course ticket. |
---|
| 118 | |
---|
[8583] | 119 | """ |
---|
| 120 | |
---|
[9496] | 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 | |
---|
[8867] | 131 | class ICustomStudentUpdateByRegNo(INigeriaStudentUpdateByRegNo): |
---|
[8583] | 132 | """Representation of a student. Skip regular reg_number validation. |
---|
| 133 | |
---|
| 134 | """ |
---|
| 135 | |
---|
[8867] | 136 | class ICustomStudentUpdateByMatricNo(INigeriaStudentUpdateByMatricNo): |
---|
[8583] | 137 | """Representation of a student. Skip regular matric_number validation. |
---|
| 138 | |
---|
[8867] | 139 | """ |
---|