source: main/waeup.kofa/trunk/src/waeup/kofa/university/department.py @ 10178

Last change on this file since 10178 was 10064, checked in by Henrik Bettermann, 12 years ago

Add more local course adviser roles.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.8 KB
Line 
1## $Id: department.py 10064 2013-04-06 04:53:30Z 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"""University departments.
19"""
20import grok
21import zope.location.location
22from zope.component.interfaces import IFactory
23from zope.interface import implementedBy
24from zope.component import getUtility
25from waeup.kofa.university.coursescontainer import CoursesContainer
26from waeup.kofa.university.certificatescontainer import CertificatesContainer
27from waeup.kofa.utils.batching import VirtualExportJobContainer
28from waeup.kofa.interfaces import IKofaUtils
29from waeup.kofa.university.interfaces import IDepartment, IDepartmentAdd
30
31class VirtualDepartmentExportJobContainer(VirtualExportJobContainer):
32    """A virtual export job container for departments.
33    """
34
35class Department(grok.Container):
36    """A university department.
37    """
38    grok.implements(IDepartment, IDepartmentAdd)
39
40    local_roles = [
41        'waeup.local.DepartmentManager',
42        'waeup.local.ClearanceOfficer',
43        'waeup.local.UGClearanceOfficer',
44        'waeup.local.PGClearanceOfficer',
45        'waeup.local.CourseAdviser100',
46        'waeup.local.CourseAdviser200',
47        'waeup.local.CourseAdviser300',
48        'waeup.local.CourseAdviser400',
49        'waeup.local.CourseAdviser500',
50        'waeup.local.CourseAdviser600',
51        'waeup.local.CourseAdviser700',
52        'waeup.local.CourseAdviser800',
53        ]
54
55    def __init__(self,
56                 title=u'Unnamed Department',
57                 title_prefix=u'department',
58                 code=u"NA", **kw):
59        super(Department, self).__init__(**kw)
60        self.title = title
61        self.title_prefix = title_prefix
62        self.code = code
63        self.courses = CoursesContainer()
64        self.courses.__parent__ = self
65        self.courses.__name__ = 'courses'
66        self.certificates = CertificatesContainer()
67        self.certificates.__parent__ = self
68        self.certificates.__name__ = 'certificates'
69
70    def traverse(self, name):
71        """Deliver appropriate containers, if someone wants to go to courses
72        or departments.
73        """
74        if name == 'courses':
75            return self.courses
76        elif name == 'certificates':
77            return self.certificates
78        elif name == 'exports':
79            # create a virtual exports container and return it
80            container = VirtualDepartmentExportJobContainer()
81            zope.location.location.located(container, self, 'exports')
82            return container
83        return None
84
85    def longtitle(self):
86        insttypes_dict = getUtility(IKofaUtils).INST_TYPES_DICT
87        return "%s %s (%s)" % (
88            insttypes_dict[self.title_prefix],
89            self.title, self.code)
90
91class DepartmentFactory(grok.GlobalUtility):
92    """A factory for department containers.
93    """
94    grok.implements(IFactory)
95    grok.name(u'waeup.Department')
96    title = u"Create a new department.",
97    description = u"This factory instantiates new department instances."
98
99    def __call__(self, *args, **kw):
100        return Department(*args, **kw)
101
102    def getInterfaces(self):
103        """Get interfaces of objects provided by this factory.
104        """
105        return implementedBy(Department)
Note: See TracBrowser for help on using the repository browser.