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

Last change on this file since 16982 was 16824, checked in by Henrik Bettermann, 3 years ago

Add missing import.

  • Property svn:keywords set to Id
File size: 2.7 KB
Line 
1## $Id: student.py 16824 2022-02-21 18:30:15Z 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, IMedicalHistory)
32
33
34class CustomStudent(NigeriaStudent):
35    """This is a student container for the various objects
36    owned by students.
37    """
38    grok.implements(
39        ICustomStudent, IStudentNavigation, ICustomStudentPersonalEdit,
40        IMedicalHistory)
41    grok.provides(ICustomStudent)
42
43    @property
44    def transcript_enabled(self):
45        return True
46        #user = get_current_principal()
47        #if user.id in ('admin', 'isouaba', 'med', 'zope.mgr'):
48        #    return True
49        #return False
50
51    @property
52    def is_jupeb(self):
53        if self.current_mode == 'found':
54            return True
55        return
56
57    @property
58    def clearance_locked(self):
59        return self.state not in (CLEARANCE, )
60
61    @property
62    def studycourse_locked(self):
63        # return self.state in (GRADUATED, TRANSREL, TRANSVAL)
64        return self.state in (TRANSREL, TRANSVAL)
65
66
67# Set all attributes of Student required in IStudent as field
68# properties. Doing this, we do not have to set initial attributes
69# ourselves and as a bonus we get free validation when an attribute is
70# set.
71CustomStudent = attrs_to_fields(CustomStudent)
72
73class CustomStudentFactory(StudentFactory):
74    """A factory for students.
75    """
76
77    def __call__(self, *args, **kw):
78        return CustomStudent()
79
80    def getInterfaces(self):
81        return implementedBy(CustomStudent)
Note: See TracBrowser for help on using the repository browser.