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

Last change on this file since 9792 was 9734, checked in by uli, 12 years ago

Try to make clearer where we head to regarding filtered exports.

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