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

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

Add local department officer role which is allowed to export payments overviews only.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.9 KB
Line 
1## $Id: department.py 10279 2013-06-06 05:15:00Z 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.ApplicationsManager',
42        'waeup.local.DepartmentOfficer',
43        'waeup.local.DepartmentManager',
44        'waeup.local.ClearanceOfficer',
45        'waeup.local.UGClearanceOfficer',
46        'waeup.local.PGClearanceOfficer',
47        'waeup.local.CourseAdviser100',
48        'waeup.local.CourseAdviser200',
49        'waeup.local.CourseAdviser300',
50        'waeup.local.CourseAdviser400',
51        'waeup.local.CourseAdviser500',
52        'waeup.local.CourseAdviser600',
53        'waeup.local.CourseAdviser700',
54        'waeup.local.CourseAdviser800',
55        ]
56
57    def __init__(self,
58                 title=u'Unnamed Department',
59                 title_prefix=u'department',
60                 code=u"NA", **kw):
61        super(Department, self).__init__(**kw)
62        self.title = title
63        self.title_prefix = title_prefix
64        self.code = code
65        self.courses = CoursesContainer()
66        self.courses.__parent__ = self
67        self.courses.__name__ = 'courses'
68        self.certificates = CertificatesContainer()
69        self.certificates.__parent__ = self
70        self.certificates.__name__ = 'certificates'
71
72    def traverse(self, name):
73        """Deliver appropriate containers, if someone wants to go to courses
74        or departments.
75        """
76        if name == 'courses':
77            return self.courses
78        elif name == 'certificates':
79            return self.certificates
80        elif name == 'exports':
81            # create a virtual exports container and return it
82            container = VirtualDepartmentExportJobContainer()
83            zope.location.location.located(container, self, 'exports')
84            return container
85        return None
86
87    def longtitle(self):
88        insttypes_dict = getUtility(IKofaUtils).INST_TYPES_DICT
89        return "%s %s (%s)" % (
90            insttypes_dict[self.title_prefix],
91            self.title, self.code)
92
93class DepartmentFactory(grok.GlobalUtility):
94    """A factory for department containers.
95    """
96    grok.implements(IFactory)
97    grok.name(u'waeup.Department')
98    title = u"Create a new department.",
99    description = u"This factory instantiates new department instances."
100
101    def __call__(self, *args, **kw):
102        return Department(*args, **kw)
103
104    def getInterfaces(self):
105        """Get interfaces of objects provided by this factory.
106        """
107        return implementedBy(Department)
Note: See TracBrowser for help on using the repository browser.