[7195] | 1 | ## $Id: faculty.py 10684 2013-11-02 08:50:58Z 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 ( |
---|
[10684] | 27 | IFaculty, IDepartment) |
---|
[3526] | 28 | |
---|
[10561] | 29 | def longtitle(inst): |
---|
| 30 | insttypes_dict = getUtility(IKofaUtils).INST_TYPES_DICT |
---|
| 31 | if inst.title_prefix == 'none': |
---|
| 32 | return "%s (%s)" % (inst.title, inst.code) |
---|
| 33 | return "%s %s (%s)" % ( |
---|
| 34 | insttypes_dict[inst.title_prefix], |
---|
| 35 | inst.title, inst.code) |
---|
| 36 | |
---|
[4789] | 37 | class Faculty(grok.Container): |
---|
| 38 | """A university faculty. |
---|
| 39 | """ |
---|
[10684] | 40 | grok.implements(IFaculty) |
---|
[3526] | 41 | |
---|
[8993] | 42 | local_roles = [ |
---|
[10279] | 43 | 'waeup.local.DepartmentOfficer', |
---|
[8993] | 44 | 'waeup.local.DepartmentManager', |
---|
| 45 | 'waeup.local.ClearanceOfficer', |
---|
| 46 | 'waeup.local.UGClearanceOfficer', |
---|
| 47 | 'waeup.local.PGClearanceOfficer', |
---|
| 48 | 'waeup.local.CourseAdviser100', |
---|
| 49 | 'waeup.local.CourseAdviser200', |
---|
| 50 | 'waeup.local.CourseAdviser300', |
---|
| 51 | 'waeup.local.CourseAdviser400', |
---|
| 52 | 'waeup.local.CourseAdviser500', |
---|
| 53 | 'waeup.local.CourseAdviser600', |
---|
[10064] | 54 | 'waeup.local.CourseAdviser700', |
---|
| 55 | 'waeup.local.CourseAdviser800', |
---|
[10639] | 56 | 'waeup.local.LocalStudentsManager', |
---|
| 57 | 'waeup.local.LocalWorkflowManager', |
---|
[8993] | 58 | ] |
---|
[6145] | 59 | |
---|
[4789] | 60 | def __init__(self, |
---|
| 61 | title=u'Unnamed Faculty', |
---|
| 62 | title_prefix=u'faculty', |
---|
| 63 | code=u'NA', **kw): |
---|
[3526] | 64 | super(Faculty, self).__init__(**kw) |
---|
[4789] | 65 | self.title = title |
---|
| 66 | self.title_prefix = title_prefix |
---|
| 67 | self.code = code |
---|
[3526] | 68 | |
---|
[4789] | 69 | def addDepartment(self, department): |
---|
| 70 | """Add a department to the faculty. |
---|
| 71 | """ |
---|
| 72 | if not IDepartment.providedBy(department): |
---|
| 73 | raise TypeError('Faculties contain only IDepartment instances') |
---|
| 74 | self[department.code] = department |
---|
[3526] | 75 | |
---|
[10650] | 76 | @property |
---|
[5988] | 77 | def longtitle(self): |
---|
[10561] | 78 | return longtitle(self) |
---|
[6145] | 79 | |
---|
[4789] | 80 | class FacultyFactory(grok.GlobalUtility): |
---|
| 81 | """A factory for faculty containers. |
---|
| 82 | """ |
---|
| 83 | grok.implements(IFactory) |
---|
| 84 | grok.name(u'waeup.Faculty') |
---|
| 85 | title = u"Create a new faculty.", |
---|
| 86 | description = u"This factory instantiates new faculty instances." |
---|
| 87 | |
---|
| 88 | def __call__(self, *args, **kw): |
---|
| 89 | return Faculty() |
---|
| 90 | |
---|
| 91 | def getInterfaces(self): |
---|
| 92 | return implementedBy(Faculty) |
---|