source: main/waeup.sirp/trunk/src/waeup/sirp/university/department.py @ 6718

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

The student section gets its own permissions module. Define new local and global roles (Students Officer, Clearance Officer & Course Adviser).

  • Property svn:eol-style set to native
File size: 2.2 KB
Line 
1"""University departments.
2"""
3import grok
4from zope.component import createObject
5from zope.component.interfaces import IFactory
6from zope.interface import implementedBy
7from waeup.sirp.university.interfaces import IDepartment, IDepartmentAdd
8from waeup.sirp.university.vocabularies import inst_types
9
10class Department(grok.Container):
11    """A university department.
12    """
13    grok.implements(IDepartment, IDepartmentAdd)
14
15    @property       # Make this method read_only and looking like an attr.
16    def local_roles(cls):
17        return ['waeup.local.DepartmentOfficer', 'waeup.local.ClearanceOfficer']
18
19    # A simple counter for ids.
20    next_id = 0L
21
22    def __init__(self,
23                 title=u'Unnamed Department',
24                 title_prefix=u'department',
25                 code=u"NA", **kw):
26        super(Department, self).__init__(**kw)
27        self.title = title
28        self.title_prefix = title_prefix
29        self.code = code
30        self.courses = createObject(u'waeup.CourseContainer')
31        self.courses.__parent__ = self
32        self.courses.__name__ = 'courses'
33        self.certificates = createObject(u'waeup.CertificateContainer')
34        self.certificates.__parent__ = self
35        self.certificates.__name__ = 'certificates'
36
37    def traverse(self, name):
38        """Deliver appropriate containers, if someone wants to go to courses
39        or departments.
40        """
41        if name == 'courses':
42            return self.courses
43        elif name == 'certificates':
44            return self.certificates
45        return None
46       
47    def longtitle(self):
48        return "%s %s (%s)" % (inst_types.getTerm(self.title_prefix).title,
49                                                  self.title,
50                                                  self.code)
51       
52
53class DepartmentFactory(grok.GlobalUtility):
54    """A factory for department containers.
55    """
56    grok.implements(IFactory)
57    grok.name(u'waeup.Department')
58    title = u"Create a new department.",
59    description = u"This factory instantiates new department instances."
60
61    def __call__(self, *args, **kw):
62        return Department(*args, **kw)
63
64    def getInterfaces(self):
65        """Get interfaces of objects provided by this factory.
66        """
67        return implementedBy(Department)
Note: See TracBrowser for help on using the repository browser.