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

Last change on this file since 10687 was 7729, checked in by uli, 13 years ago

Remove classmethod as it is not compatible with getattr.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.8 KB
RevLine 
[7195]1## $Id: faculty.py 7729 2012-02-29 15:33:35Z uli $
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##
[4789]18"""Faculty components.
19"""
20
[3526]21import grok
[4789]22from zope.component.interfaces import IFactory
23from zope.interface import implementedBy
[7681]24from zope.component import getUtility
25from waeup.sirp.interfaces import ISIRPUtils
[5953]26from waeup.sirp.university.interfaces import (
27    IFaculty, IFacultyAdd, IDepartment)
[3526]28
[4789]29class Faculty(grok.Container):
30    """A university faculty.
31    """
[5953]32    grok.implements(IFaculty, IFacultyAdd)
[3526]33
[6145]34    @property       # Make this method read_only and looking like an attr.
[7729]35    def local_roles(self):
[7185]36        return ['waeup.local.DepartmentManager',
[7334]37                'waeup.local.ClearanceOfficer',
38                'waeup.local.CourseAdviser100',
39                'waeup.local.CourseAdviser200',
40                'waeup.local.CourseAdviser300',
41                'waeup.local.CourseAdviser400',
42                'waeup.local.CourseAdviser500',
43                'waeup.local.CourseAdviser600',
44                ]
[6145]45
[4789]46    def __init__(self,
47                 title=u'Unnamed Faculty',
48                 title_prefix=u'faculty',
49                 code=u'NA', **kw):
[3526]50        super(Faculty, self).__init__(**kw)
[4789]51        self.title = title
52        self.title_prefix = title_prefix
53        self.code = code
[3526]54
[4789]55    def addDepartment(self, department):
56        """Add a department to the faculty.
57        """
58        if not IDepartment.providedBy(department):
59            raise TypeError('Faculties contain only IDepartment instances')
60        self[department.code] = department
[3526]61
[5988]62    def longtitle(self):
[7681]63        insttypes_dict = getUtility(ISIRPUtils).getInstTypeDict()
64        result = "%s %s (%s)" % (
65            insttypes_dict[self.title_prefix],
66            self.title, self.code)
[5994]67        return result
[6145]68
[4789]69class FacultyFactory(grok.GlobalUtility):
70    """A factory for faculty containers.
71    """
72    grok.implements(IFactory)
73    grok.name(u'waeup.Faculty')
74    title = u"Create a new faculty.",
75    description = u"This factory instantiates new faculty instances."
76
77    def __call__(self, *args, **kw):
78        return Faculty()
79
80    def getInterfaces(self):
81        return implementedBy(Faculty)
Note: See TracBrowser for help on using the repository browser.