source: main/waeup.kofa/trunk/src/waeup/kofa/university/faculty.py @ 13354

Last change on this file since 13354 was 12632, checked in by Henrik Bettermann, 10 years ago

Add components to configure a student export jobs in faculties.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.6 KB
RevLine 
[7195]1## $Id: faculty.py 12632 2015-02-26 07:35: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]21import grok
[12632]22import zope.location.location
[4789]23from zope.component.interfaces import IFactory
24from zope.interface import implementedBy
[7681]25from zope.component import getUtility
[7819]26from waeup.kofa.interfaces import IKofaUtils
[12632]27from waeup.kofa.utils.batching import VirtualExportJobContainer
[7811]28from waeup.kofa.university.interfaces import (
[10684]29    IFaculty, IDepartment)
[3526]30
[10561]31def longtitle(inst):
32    insttypes_dict = getUtility(IKofaUtils).INST_TYPES_DICT
33    if inst.title_prefix == 'none':
34        return "%s (%s)" % (inst.title, inst.code)
35    return "%s %s (%s)" % (
36        insttypes_dict[inst.title_prefix],
37        inst.title, inst.code)
38
[12632]39class VirtualFacultyExportJobContainer(VirtualExportJobContainer):
40    """A virtual export job container for facultiess.
41    """
42
[4789]43class Faculty(grok.Container):
44    """A university faculty.
45    """
[10684]46    grok.implements(IFaculty)
[3526]47
[8993]48    local_roles = [
[10279]49        'waeup.local.DepartmentOfficer',
[8993]50        'waeup.local.DepartmentManager',
51        'waeup.local.ClearanceOfficer',
52        'waeup.local.UGClearanceOfficer',
53        'waeup.local.PGClearanceOfficer',
54        'waeup.local.CourseAdviser100',
55        'waeup.local.CourseAdviser200',
56        'waeup.local.CourseAdviser300',
57        'waeup.local.CourseAdviser400',
58        'waeup.local.CourseAdviser500',
59        'waeup.local.CourseAdviser600',
[10064]60        'waeup.local.CourseAdviser700',
61        'waeup.local.CourseAdviser800',
[10639]62        'waeup.local.LocalStudentsManager',
63        'waeup.local.LocalWorkflowManager',
[8993]64        ]
[6145]65
[4789]66    def __init__(self,
67                 title=u'Unnamed Faculty',
68                 title_prefix=u'faculty',
69                 code=u'NA', **kw):
[3526]70        super(Faculty, self).__init__(**kw)
[4789]71        self.title = title
72        self.title_prefix = title_prefix
73        self.code = code
[3526]74
[12632]75    def traverse(self, name):
76        """Deliver appropriate containers.
77        """
78        if name == 'exports':
79            # create a virtual exports container and return it
80            container = VirtualFacultyExportJobContainer()
81            zope.location.location.located(container, self, 'exports')
82            return container
83        return None
84
[4789]85    def addDepartment(self, department):
86        """Add a department to the faculty.
87        """
88        if not IDepartment.providedBy(department):
89            raise TypeError('Faculties contain only IDepartment instances')
90        self[department.code] = department
[3526]91
[10650]92    @property
[5988]93    def longtitle(self):
[10561]94        return longtitle(self)
[6145]95
[4789]96class FacultyFactory(grok.GlobalUtility):
97    """A factory for faculty containers.
98    """
99    grok.implements(IFactory)
100    grok.name(u'waeup.Faculty')
101    title = u"Create a new faculty.",
102    description = u"This factory instantiates new faculty instances."
103
104    def __call__(self, *args, **kw):
105        return Faculty()
106
107    def getInterfaces(self):
108        return implementedBy(Faculty)
Note: See TracBrowser for help on using the repository browser.