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

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

Remove unused clear method which was even wrong.

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1"""Faculty components.
2"""
3
4import grok
5from zope.component.interfaces import IFactory
6from zope.interface import implementedBy
7from waeup.sirp.university.interfaces import (
8    IFaculty, IFacultyAdd, IDepartment)
9from waeup.sirp.university.vocabularies import inst_types
10
11class Faculty(grok.Container):
12    """A university faculty.
13    """
14    grok.implements(IFaculty, IFacultyAdd)
15
16    @property       # Make this method read_only and looking like an attr.
17    def local_roles(cls):
18        return ['waeup.local.DepartmentOfficer',
19                'waeup.local.ClearanceOffice',]
20
21    def __init__(self,
22                 title=u'Unnamed Faculty',
23                 title_prefix=u'faculty',
24                 code=u'NA', **kw):
25        super(Faculty, self).__init__(**kw)
26        self.title = title
27        self.title_prefix = title_prefix
28        self.code = code
29
30    def addDepartment(self, department):
31        """Add a department to the faculty.
32        """
33        if not IDepartment.providedBy(department):
34            raise TypeError('Faculties contain only IDepartment instances')
35        self[department.code] = department
36
37    def longtitle(self):
38        try:
39            result = "%s %s (%s)" % (
40                inst_types.getTerm(
41                    self.title_prefix).title,
42                self.title, self.code)
43        except:
44            result = "%s (%s)" % (self.title, self.code)
45        return result
46
47class FacultyFactory(grok.GlobalUtility):
48    """A factory for faculty containers.
49    """
50    grok.implements(IFactory)
51    grok.name(u'waeup.Faculty')
52    title = u"Create a new faculty.",
53    description = u"This factory instantiates new faculty instances."
54
55    def __call__(self, *args, **kw):
56        return Faculty()
57
58    def getInterfaces(self):
59        return implementedBy(Faculty)
Note: See TracBrowser for help on using the repository browser.