source: main/waeup.kofa/trunk/src/waeup/kofa/university/faculty.py @ 10639

Last change on this file since 10639 was 10639, checked in by Henrik Bettermann, 11 years ago

Define new local roles (see uniben ticket 900).

Allow the dynamical assignment of multiple local roles.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.0 KB
Line 
1## $Id: faculty.py 10639 2013-09-22 08:54:03Z 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"""Faculty components.
19"""
20
21import grok
22from zope.component.interfaces import IFactory
23from zope.interface import implementedBy
24from zope.component import getUtility
25from waeup.kofa.interfaces import IKofaUtils
26from waeup.kofa.university.interfaces import (
27    IFaculty, IFacultyAdd, IDepartment)
28
29def longtitle(inst):
30    insttypes_dict = getUtility(IKofaUtils).INST_TYPES_DICT
31    if inst.title_prefix == 'none':
32        return "%s (%s)" % (inst.title, inst.code)
33    return "%s %s (%s)" % (
34        insttypes_dict[inst.title_prefix],
35        inst.title, inst.code)
36
37class Faculty(grok.Container):
38    """A university faculty.
39    """
40    grok.implements(IFaculty, IFacultyAdd)
41
42    local_roles = [
43        'waeup.local.DepartmentOfficer',
44        'waeup.local.DepartmentManager',
45        'waeup.local.ClearanceOfficer',
46        'waeup.local.UGClearanceOfficer',
47        'waeup.local.PGClearanceOfficer',
48        'waeup.local.CourseAdviser100',
49        'waeup.local.CourseAdviser200',
50        'waeup.local.CourseAdviser300',
51        'waeup.local.CourseAdviser400',
52        'waeup.local.CourseAdviser500',
53        'waeup.local.CourseAdviser600',
54        'waeup.local.CourseAdviser700',
55        'waeup.local.CourseAdviser800',
56        'waeup.local.LocalStudentsManager',
57        'waeup.local.LocalWorkflowManager',
58        ]
59
60    def __init__(self,
61                 title=u'Unnamed Faculty',
62                 title_prefix=u'faculty',
63                 code=u'NA', **kw):
64        super(Faculty, self).__init__(**kw)
65        self.title = title
66        self.title_prefix = title_prefix
67        self.code = code
68
69    def addDepartment(self, department):
70        """Add a department to the faculty.
71        """
72        if not IDepartment.providedBy(department):
73            raise TypeError('Faculties contain only IDepartment instances')
74        self[department.code] = department
75
76    def longtitle(self):
77        return longtitle(self)
78
79class FacultyFactory(grok.GlobalUtility):
80    """A factory for faculty containers.
81    """
82    grok.implements(IFactory)
83    grok.name(u'waeup.Faculty')
84    title = u"Create a new faculty.",
85    description = u"This factory instantiates new faculty instances."
86
87    def __call__(self, *args, **kw):
88        return Faculty()
89
90    def getInterfaces(self):
91        return implementedBy(Faculty)
Note: See TracBrowser for help on using the repository browser.