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

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

We don't need an id counter.

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