source: main/waeup.sirp/branches/henrik-bootstrap/src/waeup/sirp/university/faculty.py @ 10009

Last change on this file since 10009 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
Line 
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##
18"""Faculty components.
19"""
20
21import grok
22from zope.component.interfaces import IFactory
23from zope.interface import implementedBy
24from waeup.sirp.university.interfaces import (
25    IFaculty, IFacultyAdd, IDepartment)
26from waeup.sirp.university.vocabularies import inst_types
27
28class Faculty(grok.Container):
29    """A university faculty.
30    """
31    grok.implements(IFaculty, IFacultyAdd)
32
33    @property       # Make this method read_only and looking like an attr.
34    def local_roles(cls):
35        return ['waeup.local.DepartmentManager',
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                ]
44
45    def __init__(self,
46                 title=u'Unnamed Faculty',
47                 title_prefix=u'faculty',
48                 code=u'NA', **kw):
49        super(Faculty, self).__init__(**kw)
50        self.title = title
51        self.title_prefix = title_prefix
52        self.code = code
53
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
60
61    def longtitle(self):
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
70
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.