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
Line 
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
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_mode != 'ug_ft':
55            return False
56        if self.faccode in ('EDU', 'MED', 'DEN'):
57            return False
58        return True
59
60    @property
61    def is_jupeb(self):
62        if self.current_mode == 'found':
63            return True
64        return
65
66    @property
67    def clearance_locked(self):
68        return self.state not in (CLEARANCE, )
69
70    @property
71    def studycourse_locked(self):
72        # return self.state in (GRADUATED, TRANSREL, TRANSVAL)
73        return self.state in (TRANSREL, TRANSVAL)
74
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
87
88
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.
93CustomStudent = attrs_to_fields(CustomStudent)
94
95class CustomStudentFactory(StudentFactory):
96    """A factory for students.
97    """
98
99    def __call__(self, *args, **kw):
100        return CustomStudent()
101
102    def getInterfaces(self):
103        return implementedBy(CustomStudent)
Note: See TracBrowser for help on using the repository browser.