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

Last change on this file since 18105 was 18105, checked in by Henrik Bettermann, 10 hours ago

Disable some departments,

  • Property svn:keywords set to Id
File size: 3.6 KB
Line 
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"""
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        if self.depcode in ('ENL', 'LST'):
59            return False
60        return True
61
62    @property
63    def is_jupeb(self):
64        if self.current_mode == 'found':
65            return True
66        return
67
68    @property
69    def clearance_locked(self):
70        return self.state not in (CLEARANCE, )
71
72    @property
73    def studycourse_locked(self):
74        # return self.state in (GRADUATED, TRANSREL, TRANSVAL)
75        return self.state in (TRANSREL, TRANSVAL)
76
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
89
90
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.
95CustomStudent = attrs_to_fields(CustomStudent)
96
97class CustomStudentFactory(StudentFactory):
98    """A factory for students.
99    """
100
101    def __call__(self, *args, **kw):
102        return CustomStudent()
103
104    def getInterfaces(self):
105        return implementedBy(CustomStudent)
Note: See TracBrowser for help on using the repository browser.