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

Last change on this file since 8985 was 8965, checked in by Henrik Bettermann, 13 years ago

Make new roles selectable in UI.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.5 KB
RevLine 
[7195]1## $Id: department.py 8965 2012-07-10 05:48:24Z 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
[6152]34    @property       # Make this method read_only and looking like an attr.
[7733]35    def local_roles(self):
[7185]36        return ['waeup.local.DepartmentManager',
[7334]37                'waeup.local.ClearanceOfficer',
[8965]38                'waeup.local.UGClearanceOfficer',
39                'waeup.local.PGClearanceOfficer',
[7334]40                'waeup.local.CourseAdviser100',
41                'waeup.local.CourseAdviser200',
42                'waeup.local.CourseAdviser300',
43                'waeup.local.CourseAdviser400',
44                'waeup.local.CourseAdviser500',
45                'waeup.local.CourseAdviser600',
46                ]
[6152]47
[4789]48    # A simple counter for ids.
49    next_id = 0L
[6152]50
[4789]51    def __init__(self,
52                 title=u'Unnamed Department',
53                 title_prefix=u'department',
54                 code=u"NA", **kw):
55        super(Department, self).__init__(**kw)
56        self.title = title
57        self.title_prefix = title_prefix
58        self.code = code
[7681]59        self.courses = CoursesContainer()
[4789]60        self.courses.__parent__ = self
61        self.courses.__name__ = 'courses'
[7681]62        self.certificates = CertificatesContainer()
[4789]63        self.certificates.__parent__ = self
64        self.certificates.__name__ = 'certificates'
65
66    def traverse(self, name):
67        """Deliver appropriate containers, if someone wants to go to courses
68        or departments.
69        """
70        if name == 'courses':
71            return self.courses
72        elif name == 'certificates':
73            return self.certificates
74        return None
[6813]75
[5988]76    def longtitle(self):
[7841]77        insttypes_dict = getUtility(IKofaUtils).INST_TYPES_DICT
[6813]78        return "%s %s (%s)" % (
[7681]79            insttypes_dict[self.title_prefix],
[6813]80            self.title, self.code)
[4789]81
[6813]82
[4789]83class DepartmentFactory(grok.GlobalUtility):
84    """A factory for department containers.
85    """
86    grok.implements(IFactory)
87    grok.name(u'waeup.Department')
88    title = u"Create a new department.",
89    description = u"This factory instantiates new department instances."
90
91    def __call__(self, *args, **kw):
92        return Department(*args, **kw)
93
94    def getInterfaces(self):
95        """Get interfaces of objects provided by this factory.
96        """
97        return implementedBy(Department)
Note: See TracBrowser for help on using the repository browser.