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

Last change on this file since 8970 was 8965, checked in by Henrik Bettermann, 13 years ago

Make new roles selectable in UI.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.9 KB
Line 
1## $Id: faculty.py 8965 2012-07-10 05:48:24Z 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
29class Faculty(grok.Container):
30    """A university faculty.
31    """
32    grok.implements(IFaculty, IFacultyAdd)
33
34    @property       # Make this method read_only and looking like an attr.
35    def local_roles(self):
36        return ['waeup.local.DepartmentManager',
37                'waeup.local.ClearanceOfficer',
38                'waeup.local.UGClearanceOfficer',
39                'waeup.local.PGClearanceOfficer',
40                'waeup.local.CourseAdviser100',
41                'waeup.local.CourseAdviser200',
42                'waeup.local.CourseAdviser300',
43                'waeup.local.CourseAdviser400',
44                'waeup.local.CourseAdviser500',
45                'waeup.local.CourseAdviser600',
46                ]
47
48    def __init__(self,
49                 title=u'Unnamed Faculty',
50                 title_prefix=u'faculty',
51                 code=u'NA', **kw):
52        super(Faculty, self).__init__(**kw)
53        self.title = title
54        self.title_prefix = title_prefix
55        self.code = code
56
57    def addDepartment(self, department):
58        """Add a department to the faculty.
59        """
60        if not IDepartment.providedBy(department):
61            raise TypeError('Faculties contain only IDepartment instances')
62        self[department.code] = department
63
64    def longtitle(self):
65        insttypes_dict = getUtility(IKofaUtils).INST_TYPES_DICT
66        result = "%s %s (%s)" % (
67            insttypes_dict[self.title_prefix],
68            self.title, self.code)
69        return result
70
71class FacultyFactory(grok.GlobalUtility):
72    """A factory for faculty containers.
73    """
74    grok.implements(IFactory)
75    grok.name(u'waeup.Faculty')
76    title = u"Create a new faculty.",
77    description = u"This factory instantiates new faculty instances."
78
79    def __call__(self, *args, **kw):
80        return Faculty()
81
82    def getInterfaces(self):
83        return implementedBy(Faculty)
Note: See TracBrowser for help on using the repository browser.