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, 19 hours ago

Only 2023 session students are allowed to download transcripts.

  • Property svn:keywords set to Id
File size: 3.6 KB
RevLine 
[7505]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
[18101]23from zope.component import getUtility
[16824]24from waeup.kofa.interfaces import (
25    CLEARANCE, REQUESTED, GRADUATED, TRANSREL, TRANSVAL)
[7822]26from waeup.kofa.utils.helpers import attrs_to_fields
[8988]27from waeup.kofa.students.student import StudentFactory
[18101]28from waeup.kofa.students.interfaces import IStudentNavigation, IStudentsUtils
[10488]29from waeup.kofa.utils.helpers import get_current_principal
[8988]30from kofacustom.nigeria.students.student import NigeriaStudent
[13085]31from waeup.uniben.students.interfaces import (
[17822]32    ICustomStudent, ICustomStudentPersonalEdit,
33    IMedicalHistory, ITiship, INYSC)
[7505]34
35
[8988]36class 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
[18123]54        if self.current_session != 2023:
55            return False
[18101]56        if self.current_mode != 'ug_ft':
57            return False
58        if self.faccode in ('EDU', 'MED', 'DEN'):
59            return False
[18105]60        if self.depcode in ('ENL', 'LST'):
61            return False
[18101]62        return True
[7505]63
[14902]64    @property
65    def is_jupeb(self):
[16337]66        if self.current_mode == 'found':
[14902]67            return True
[16371]68        return
[10312]69
[16371]70    @property
71    def clearance_locked(self):
[16688]72        return self.state not in (CLEARANCE, )
[14902]73
[16823]74    @property
75    def studycourse_locked(self):
76        # return self.state in (GRADUATED, TRANSREL, TRANSVAL)
77        return self.state in (TRANSREL, TRANSVAL)
[16371]78
[17822]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
[16823]91
[17822]92
[7505]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.
[8204]97CustomStudent = attrs_to_fields(CustomStudent)
[7603]98
[8204]99class CustomStudentFactory(StudentFactory):
[7603]100    """A factory for students.
101    """
102
103    def __call__(self, *args, **kw):
[8204]104        return CustomStudent()
[7603]105
106    def getInterfaces(self):
[8204]107        return implementedBy(CustomStudent)
Note: See TracBrowser for help on using the repository browser.