[7505] | 1 | ## $Id: student.py 17822 2024-06-27 07:47:23Z henrik $ |
---|
| 2 | ## |
---|
| 3 | ## Copyright (C) 2011 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 | Container for the various objects owned by students. |
---|
| 20 | """ |
---|
| 21 | import grok |
---|
| 22 | from zope.interface import implementedBy |
---|
[16824] | 23 | from waeup.kofa.interfaces import ( |
---|
| 24 | CLEARANCE, REQUESTED, GRADUATED, TRANSREL, TRANSVAL) |
---|
[7822] | 25 | from waeup.kofa.utils.helpers import attrs_to_fields |
---|
[8988] | 26 | from waeup.kofa.students.student import StudentFactory |
---|
[8865] | 27 | from waeup.kofa.students.interfaces import IStudentNavigation |
---|
[10488] | 28 | from waeup.kofa.utils.helpers import get_current_principal |
---|
[8988] | 29 | from kofacustom.nigeria.students.student import NigeriaStudent |
---|
[13085] | 30 | from waeup.uniben.students.interfaces import ( |
---|
[17822] | 31 | ICustomStudent, ICustomStudentPersonalEdit, |
---|
| 32 | IMedicalHistory, ITiship, INYSC) |
---|
[7505] | 33 | |
---|
| 34 | |
---|
[8988] | 35 | class CustomStudent(NigeriaStudent): |
---|
[7505] | 36 | """This is a student container for the various objects |
---|
| 37 | owned by students. |
---|
| 38 | """ |
---|
[13085] | 39 | grok.implements( |
---|
[16382] | 40 | ICustomStudent, IStudentNavigation, ICustomStudentPersonalEdit, |
---|
[17822] | 41 | IMedicalHistory, ITiship, INYSC) |
---|
[8204] | 42 | grok.provides(ICustomStudent) |
---|
[7505] | 43 | |
---|
[10312] | 44 | @property |
---|
| 45 | def transcript_enabled(self): |
---|
[15172] | 46 | return True |
---|
| 47 | #user = get_current_principal() |
---|
| 48 | #if user.id in ('admin', 'isouaba', 'med', 'zope.mgr'): |
---|
| 49 | # return True |
---|
| 50 | #return False |
---|
[7505] | 51 | |
---|
[14902] | 52 | @property |
---|
| 53 | def is_jupeb(self): |
---|
[16337] | 54 | if self.current_mode == 'found': |
---|
[14902] | 55 | return True |
---|
[16371] | 56 | return |
---|
[10312] | 57 | |
---|
[16371] | 58 | @property |
---|
| 59 | def clearance_locked(self): |
---|
[16688] | 60 | return self.state not in (CLEARANCE, ) |
---|
[14902] | 61 | |
---|
[16823] | 62 | @property |
---|
| 63 | def studycourse_locked(self): |
---|
| 64 | # return self.state in (GRADUATED, TRANSREL, TRANSVAL) |
---|
| 65 | return self.state in (TRANSREL, TRANSVAL) |
---|
[16371] | 66 | |
---|
[17822] | 67 | @property |
---|
| 68 | def eligible_for_nysc(self): |
---|
| 69 | if not self.current_mode.startswith('ug') \ |
---|
| 70 | and not self.current_mode.startswith('de'): |
---|
| 71 | return False |
---|
| 72 | studycourse = self['studycourse'] |
---|
| 73 | certificate = getattr(studycourse,'certificate',None) |
---|
| 74 | current_level = studycourse.current_level |
---|
| 75 | end_level = certificate.end_level |
---|
| 76 | if not self.current_level >= end_level: |
---|
| 77 | return False |
---|
| 78 | return True |
---|
[16823] | 79 | |
---|
[17822] | 80 | |
---|
[7505] | 81 | # Set all attributes of Student required in IStudent as field |
---|
| 82 | # properties. Doing this, we do not have to set initial attributes |
---|
| 83 | # ourselves and as a bonus we get free validation when an attribute is |
---|
| 84 | # set. |
---|
[8204] | 85 | CustomStudent = attrs_to_fields(CustomStudent) |
---|
[7603] | 86 | |
---|
[8204] | 87 | class CustomStudentFactory(StudentFactory): |
---|
[7603] | 88 | """A factory for students. |
---|
| 89 | """ |
---|
| 90 | |
---|
| 91 | def __call__(self, *args, **kw): |
---|
[8204] | 92 | return CustomStudent() |
---|
[7603] | 93 | |
---|
| 94 | def getInterfaces(self): |
---|
[8204] | 95 | return implementedBy(CustomStudent) |
---|