[7195] | 1 | ## $Id: faculty.py 10279 2013-06-06 05:15:00Z 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] | 21 | import grok |
---|
[4789] | 22 | from zope.component.interfaces import IFactory |
---|
| 23 | from zope.interface import implementedBy |
---|
[7681] | 24 | from zope.component import getUtility |
---|
[7819] | 25 | from waeup.kofa.interfaces import IKofaUtils |
---|
[7811] | 26 | from waeup.kofa.university.interfaces import ( |
---|
[5953] | 27 | IFaculty, IFacultyAdd, IDepartment) |
---|
[3526] | 28 | |
---|
[4789] | 29 | class Faculty(grok.Container): |
---|
| 30 | """A university faculty. |
---|
| 31 | """ |
---|
[5953] | 32 | grok.implements(IFaculty, IFacultyAdd) |
---|
[3526] | 33 | |
---|
[8993] | 34 | local_roles = [ |
---|
[10279] | 35 | 'waeup.local.DepartmentOfficer', |
---|
[8993] | 36 | 'waeup.local.DepartmentManager', |
---|
| 37 | 'waeup.local.ClearanceOfficer', |
---|
| 38 | 'waeup.local.UGClearanceOfficer', |
---|
| 39 | 'waeup.local.PGClearanceOfficer', |
---|
| 40 | 'waeup.local.CourseAdviser100', |
---|
| 41 | 'waeup.local.CourseAdviser200', |
---|
| 42 | 'waeup.local.CourseAdviser300', |
---|
| 43 | 'waeup.local.CourseAdviser400', |
---|
| 44 | 'waeup.local.CourseAdviser500', |
---|
| 45 | 'waeup.local.CourseAdviser600', |
---|
[10064] | 46 | 'waeup.local.CourseAdviser700', |
---|
| 47 | 'waeup.local.CourseAdviser800', |
---|
[8993] | 48 | ] |
---|
[6145] | 49 | |
---|
[4789] | 50 | def __init__(self, |
---|
| 51 | title=u'Unnamed Faculty', |
---|
| 52 | title_prefix=u'faculty', |
---|
| 53 | code=u'NA', **kw): |
---|
[3526] | 54 | super(Faculty, self).__init__(**kw) |
---|
[4789] | 55 | self.title = title |
---|
| 56 | self.title_prefix = title_prefix |
---|
| 57 | self.code = code |
---|
[3526] | 58 | |
---|
[4789] | 59 | def addDepartment(self, department): |
---|
| 60 | """Add a department to the faculty. |
---|
| 61 | """ |
---|
| 62 | if not IDepartment.providedBy(department): |
---|
| 63 | raise TypeError('Faculties contain only IDepartment instances') |
---|
| 64 | self[department.code] = department |
---|
[3526] | 65 | |
---|
[5988] | 66 | def longtitle(self): |
---|
[7841] | 67 | insttypes_dict = getUtility(IKofaUtils).INST_TYPES_DICT |
---|
[7681] | 68 | result = "%s %s (%s)" % ( |
---|
| 69 | insttypes_dict[self.title_prefix], |
---|
| 70 | self.title, self.code) |
---|
[5994] | 71 | return result |
---|
[6145] | 72 | |
---|
[4789] | 73 | class FacultyFactory(grok.GlobalUtility): |
---|
| 74 | """A factory for faculty containers. |
---|
| 75 | """ |
---|
| 76 | grok.implements(IFactory) |
---|
| 77 | grok.name(u'waeup.Faculty') |
---|
| 78 | title = u"Create a new faculty.", |
---|
| 79 | description = u"This factory instantiates new faculty instances." |
---|
| 80 | |
---|
| 81 | def __call__(self, *args, **kw): |
---|
| 82 | return Faculty() |
---|
| 83 | |
---|
| 84 | def getInterfaces(self): |
---|
| 85 | return implementedBy(Faculty) |
---|