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

Last change on this file since 17881 was 17822, checked in by Henrik Bettermann, 6 months ago

Implement NYSC request pages.

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