source: main/waeup.sirp/trunk/src/waeup/sirp/university/faculty.py @ 7206

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

More copyright adjustments.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.5 KB
Line 
1## $Id: faculty.py 7195 2011-11-25 07:34:07Z 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 waeup.sirp.university.interfaces import (
25    IFaculty, IFacultyAdd, IDepartment)
26from waeup.sirp.university.vocabularies import inst_types
27
28class Faculty(grok.Container):
29    """A university faculty.
30    """
31    grok.implements(IFaculty, IFacultyAdd)
32
33    @property       # Make this method read_only and looking like an attr.
34    def local_roles(cls):
35        return ['waeup.local.DepartmentManager',
36                'waeup.local.ClearanceOfficer',]
37
38    def __init__(self,
39                 title=u'Unnamed Faculty',
40                 title_prefix=u'faculty',
41                 code=u'NA', **kw):
42        super(Faculty, self).__init__(**kw)
43        self.title = title
44        self.title_prefix = title_prefix
45        self.code = code
46
47    def addDepartment(self, department):
48        """Add a department to the faculty.
49        """
50        if not IDepartment.providedBy(department):
51            raise TypeError('Faculties contain only IDepartment instances')
52        self[department.code] = department
53
54    def longtitle(self):
55        try:
56            result = "%s %s (%s)" % (
57                inst_types.getTerm(
58                    self.title_prefix).title,
59                self.title, self.code)
60        except:
61            result = "%s (%s)" % (self.title, self.code)
62        return result
63
64class FacultyFactory(grok.GlobalUtility):
65    """A factory for faculty containers.
66    """
67    grok.implements(IFactory)
68    grok.name(u'waeup.Faculty')
69    title = u"Create a new faculty.",
70    description = u"This factory instantiates new faculty instances."
71
72    def __call__(self, *args, **kw):
73        return Faculty()
74
75    def getInterfaces(self):
76        return implementedBy(Faculty)
Note: See TracBrowser for help on using the repository browser.