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