source: main/waeup.kofa/branches/uli-async-update/src/waeup/kofa/university/department.py @ 10009

Last change on this file since 10009 was 9169, checked in by uli, 12 years ago

Merge changes from trunk, r8786-HEAD

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.3 KB
RevLine 
[7195]1## $Id: department.py 9169 2012-09-10 11:05:07Z 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##
[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
[9169]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    # A simple counter for ids.
48    next_id = 0L
[6152]49
[4789]50    def __init__(self,
51                 title=u'Unnamed Department',
52                 title_prefix=u'department',
53                 code=u"NA", **kw):
54        super(Department, self).__init__(**kw)
55        self.title = title
56        self.title_prefix = title_prefix
57        self.code = code
[7681]58        self.courses = CoursesContainer()
[4789]59        self.courses.__parent__ = self
60        self.courses.__name__ = 'courses'
[7681]61        self.certificates = CertificatesContainer()
[4789]62        self.certificates.__parent__ = self
63        self.certificates.__name__ = 'certificates'
64
65    def traverse(self, name):
66        """Deliver appropriate containers, if someone wants to go to courses
67        or departments.
68        """
69        if name == 'courses':
70            return self.courses
71        elif name == 'certificates':
72            return self.certificates
73        return None
[6813]74
[5988]75    def longtitle(self):
[7841]76        insttypes_dict = getUtility(IKofaUtils).INST_TYPES_DICT
[6813]77        return "%s %s (%s)" % (
[7681]78            insttypes_dict[self.title_prefix],
[6813]79            self.title, self.code)
[4789]80
[6813]81
[4789]82class DepartmentFactory(grok.GlobalUtility):
83    """A factory for department containers.
84    """
85    grok.implements(IFactory)
86    grok.name(u'waeup.Department')
87    title = u"Create a new department.",
88    description = u"This factory instantiates new department instances."
89
90    def __call__(self, *args, **kw):
91        return Department(*args, **kw)
92
93    def getInterfaces(self):
94        """Get interfaces of objects provided by this factory.
95        """
96        return implementedBy(Department)
Note: See TracBrowser for help on using the repository browser.