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

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

We do not need IFacultyAdd. A simple omit('code') does the same job.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.0 KB
Line 
1## $Id: faculty.py 10684 2013-11-02 08:50:58Z 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, 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)
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    @property
77    def longtitle(self):
78        return longtitle(self)
79
80class FacultyFactory(grok.GlobalUtility):
81    """A factory for faculty containers.
82    """
83    grok.implements(IFactory)
84    grok.name(u'waeup.Faculty')
85    title = u"Create a new faculty.",
86    description = u"This factory instantiates new faculty instances."
87
88    def __call__(self, *args, **kw):
89        return Faculty()
90
91    def getInterfaces(self):
92        return implementedBy(Faculty)
Note: See TracBrowser for help on using the repository browser.