source: main/waeup.uniben/trunk/src/waeup/uniben/students/student.py @ 18123

Last change on this file since 18123 was 18123, checked in by Henrik Bettermann, 11 hours ago

Only 2023 session students are allowed to download transcripts.

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