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

Last change on this file since 18101 was 18101, checked in by Henrik Bettermann, 6 days ago

Enable transcripts.

  • Property svn:keywords set to Id
File size: 3.5 KB
RevLine 
[7505]1## $Id: student.py 18101 2025-06-30 11:56:08Z 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
54        if self.current_mode != 'ug_ft':
55            return False
56        if self.faccode in ('EDU', 'MED', 'DEN'):
57            return False
58        return True
[7505]59
[14902]60    @property
61    def is_jupeb(self):
[16337]62        if self.current_mode == 'found':
[14902]63            return True
[16371]64        return
[10312]65
[16371]66    @property
67    def clearance_locked(self):
[16688]68        return self.state not in (CLEARANCE, )
[14902]69
[16823]70    @property
71    def studycourse_locked(self):
72        # return self.state in (GRADUATED, TRANSREL, TRANSVAL)
73        return self.state in (TRANSREL, TRANSVAL)
[16371]74
[17822]75    @property
76    def eligible_for_nysc(self):
77        if not self.current_mode.startswith('ug') \
78            and not self.current_mode.startswith('de'):
79            return False
80        studycourse = self['studycourse']
81        certificate = getattr(studycourse,'certificate',None)
82        current_level = studycourse.current_level
83        end_level = certificate.end_level
84        if not self.current_level >= end_level:
85            return False
86        return True
[16823]87
[17822]88
[7505]89# Set all attributes of Student required in IStudent as field
90# properties. Doing this, we do not have to set initial attributes
91# ourselves and as a bonus we get free validation when an attribute is
92# set.
[8204]93CustomStudent = attrs_to_fields(CustomStudent)
[7603]94
[8204]95class CustomStudentFactory(StudentFactory):
[7603]96    """A factory for students.
97    """
98
99    def __call__(self, *args, **kw):
[8204]100        return CustomStudent()
[7603]101
102    def getInterfaces(self):
[8204]103        return implementedBy(CustomStudent)
Note: See TracBrowser for help on using the repository browser.