source: main/waeup.sirp/trunk/src/waeup/sirp/university/faculty.py @ 7484

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

Implement local CourseAdviser? roles. These roles can be assigned in departments and certificates. There are 6 different roles, one for each study level. getRolesForPrincipal grants the additional waeup.StudentsCourseAdviser? role only if the current level of a student corresponds with the level number in the external role name.

To do: Assign local roles on CertificateManageFormPage?. Add browser tests.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.8 KB
RevLine 
[7195]1## $Id: faculty.py 7334 2011-12-12 14:11:21Z 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"""Faculty components.
19"""
20
[3526]21import grok
[4789]22from zope.component.interfaces import IFactory
23from zope.interface import implementedBy
[5953]24from waeup.sirp.university.interfaces import (
25    IFaculty, IFacultyAdd, IDepartment)
[6145]26from waeup.sirp.university.vocabularies import inst_types
[3526]27
[4789]28class Faculty(grok.Container):
29    """A university faculty.
30    """
[5953]31    grok.implements(IFaculty, IFacultyAdd)
[3526]32
[6145]33    @property       # Make this method read_only and looking like an attr.
34    def local_roles(cls):
[7185]35        return ['waeup.local.DepartmentManager',
[7334]36                'waeup.local.ClearanceOfficer',
37                'waeup.local.CourseAdviser100',
38                'waeup.local.CourseAdviser200',
39                'waeup.local.CourseAdviser300',
40                'waeup.local.CourseAdviser400',
41                'waeup.local.CourseAdviser500',
42                'waeup.local.CourseAdviser600',
43                ]
[6145]44
[4789]45    def __init__(self,
46                 title=u'Unnamed Faculty',
47                 title_prefix=u'faculty',
48                 code=u'NA', **kw):
[3526]49        super(Faculty, self).__init__(**kw)
[4789]50        self.title = title
51        self.title_prefix = title_prefix
52        self.code = code
[3526]53
[4789]54    def addDepartment(self, department):
55        """Add a department to the faculty.
56        """
57        if not IDepartment.providedBy(department):
58            raise TypeError('Faculties contain only IDepartment instances')
59        self[department.code] = department
[3526]60
[5988]61    def longtitle(self):
[5994]62        try:
63            result = "%s %s (%s)" % (
64                inst_types.getTerm(
65                    self.title_prefix).title,
66                self.title, self.code)
67        except:
68            result = "%s (%s)" % (self.title, self.code)
69        return result
[6145]70
[4789]71class FacultyFactory(grok.GlobalUtility):
72    """A factory for faculty containers.
73    """
74    grok.implements(IFactory)
75    grok.name(u'waeup.Faculty')
76    title = u"Create a new faculty.",
77    description = u"This factory instantiates new faculty instances."
78
79    def __call__(self, *args, **kw):
80        return Faculty()
81
82    def getInterfaces(self):
83        return implementedBy(Faculty)
Note: See TracBrowser for help on using the repository browser.