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

Last change on this file since 12704 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
Line 
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##
18"""Faculty components.
19"""
20
21import grok
22import zope.location.location
23from zope.component.interfaces import IFactory
24from zope.interface import implementedBy
25from zope.component import getUtility
26from waeup.kofa.interfaces import IKofaUtils
27from waeup.kofa.utils.batching import VirtualExportJobContainer
28from waeup.kofa.university.interfaces import (
29    IFaculty, IDepartment)
30
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
39class VirtualFacultyExportJobContainer(VirtualExportJobContainer):
40    """A virtual export job container for facultiess.
41    """
42
43class Faculty(grok.Container):
44    """A university faculty.
45    """
46    grok.implements(IFaculty)
47
48    local_roles = [
49        'waeup.local.DepartmentOfficer',
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',
60        'waeup.local.CourseAdviser700',
61        'waeup.local.CourseAdviser800',
62        'waeup.local.LocalStudentsManager',
63        'waeup.local.LocalWorkflowManager',
64        ]
65
66    def __init__(self,
67                 title=u'Unnamed Faculty',
68                 title_prefix=u'faculty',
69                 code=u'NA', **kw):
70        super(Faculty, self).__init__(**kw)
71        self.title = title
72        self.title_prefix = title_prefix
73        self.code = code
74
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
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
91
92    @property
93    def longtitle(self):
94        return longtitle(self)
95
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.