source: main/waeup.sirp/trunk/src/waeup/sirp/university/department.py @ 7333

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

Rename certificatecontainer, coursecontainer and facultycontainer. Now we have e.g. a container for faculties. Synonyms are 'facultiescontainer', 'faculties', 'academics' or 'Academic Section'. The faculty container is the faculty itself which contains the departments.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.9 KB
Line 
1## $Id: department.py 7333 2011-12-12 07:01:54Z 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
21from zope.component import createObject
22from zope.component.interfaces import IFactory
23from zope.interface import implementedBy
24from waeup.sirp.university.interfaces import IDepartment, IDepartmentAdd
25from waeup.sirp.university.vocabularies import inst_types
26
27class Department(grok.Container):
28    """A university department.
29    """
30    grok.implements(IDepartment, IDepartmentAdd)
31
32    @property       # Make this method read_only and looking like an attr.
33    def local_roles(cls):
34        return ['waeup.local.DepartmentManager',
35                'waeup.local.ClearanceOfficer',]
36
37    # A simple counter for ids.
38    next_id = 0L
39
40    def __init__(self,
41                 title=u'Unnamed Department',
42                 title_prefix=u'department',
43                 code=u"NA", **kw):
44        super(Department, self).__init__(**kw)
45        self.title = title
46        self.title_prefix = title_prefix
47        self.code = code
48        self.courses = createObject(u'waeup.CoursesContainer')
49        self.courses.__parent__ = self
50        self.courses.__name__ = 'courses'
51        self.certificates = createObject(u'waeup.CertificatesContainer')
52        self.certificates.__parent__ = self
53        self.certificates.__name__ = 'certificates'
54
55    def traverse(self, name):
56        """Deliver appropriate containers, if someone wants to go to courses
57        or departments.
58        """
59        if name == 'courses':
60            return self.courses
61        elif name == 'certificates':
62            return self.certificates
63        return None
64
65    def longtitle(self):
66        return "%s %s (%s)" % (
67            inst_types.getTerm(self.title_prefix).title,
68            self.title, self.code)
69
70
71class DepartmentFactory(grok.GlobalUtility):
72    """A factory for department containers.
73    """
74    grok.implements(IFactory)
75    grok.name(u'waeup.Department')
76    title = u"Create a new department.",
77    description = u"This factory instantiates new department instances."
78
79    def __call__(self, *args, **kw):
80        return Department(*args, **kw)
81
82    def getInterfaces(self):
83        """Get interfaces of objects provided by this factory.
84        """
85        return implementedBy(Department)
Note: See TracBrowser for help on using the repository browser.