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

Last change on this file since 10561 was 10561, checked in by Henrik Bettermann, 11 years ago

If no prefix is selected do not prepend a whitespace.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.8 KB
Line 
1## $Id: department.py 10561 2013-08-29 15:11:14Z 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.faculty import longtitle
26from waeup.kofa.university.coursescontainer import CoursesContainer
27from waeup.kofa.university.certificatescontainer import CertificatesContainer
28from waeup.kofa.utils.batching import VirtualExportJobContainer
29from waeup.kofa.interfaces import IKofaUtils
30from waeup.kofa.university.interfaces import IDepartment, IDepartmentAdd
31
32class VirtualDepartmentExportJobContainer(VirtualExportJobContainer):
33    """A virtual export job container for departments.
34    """
35
36class Department(grok.Container):
37    """A university department.
38    """
39    grok.implements(IDepartment, IDepartmentAdd)
40
41    local_roles = [
42        'waeup.local.ApplicationsManager',
43        'waeup.local.DepartmentOfficer',
44        'waeup.local.DepartmentManager',
45        'waeup.local.ClearanceOfficer',
46        'waeup.local.UGClearanceOfficer',
47        'waeup.local.PGClearanceOfficer',
48        'waeup.local.CourseAdviser100',
49        'waeup.local.CourseAdviser200',
50        'waeup.local.CourseAdviser300',
51        'waeup.local.CourseAdviser400',
52        'waeup.local.CourseAdviser500',
53        'waeup.local.CourseAdviser600',
54        'waeup.local.CourseAdviser700',
55        'waeup.local.CourseAdviser800',
56        ]
57
58    def __init__(self,
59                 title=u'Unnamed Department',
60                 title_prefix=u'department',
61                 code=u"NA", **kw):
62        super(Department, self).__init__(**kw)
63        self.title = title
64        self.title_prefix = title_prefix
65        self.code = code
66        self.courses = CoursesContainer()
67        self.courses.__parent__ = self
68        self.courses.__name__ = 'courses'
69        self.certificates = CertificatesContainer()
70        self.certificates.__parent__ = self
71        self.certificates.__name__ = 'certificates'
72
73    def traverse(self, name):
74        """Deliver appropriate containers, if someone wants to go to courses
75        or departments.
76        """
77        if name == 'courses':
78            return self.courses
79        elif name == 'certificates':
80            return self.certificates
81        elif name == 'exports':
82            # create a virtual exports container and return it
83            container = VirtualDepartmentExportJobContainer()
84            zope.location.location.located(container, self, 'exports')
85            return container
86        return None
87
88    def longtitle(self):
89        return longtitle(self)
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.