source: main/waeup.kofa/trunk/src/waeup/kofa/university/facultiescontainer.py @ 17651

Last change on this file since 17651 was 14511, checked in by Henrik Bettermann, 8 years ago

Add officer name fields do IDepartment and IFaculty. Plugins must be updated!

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.9 KB
RevLine 
[7195]1## $Id: facultiescontainer.py 14511 2017-02-07 08:33:05Z 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##
[3526]18import grok
[10247]19import zope.location.location
[4789]20from zope.component.interfaces import IFactory
21from zope.interface import implementedBy
[7819]22from waeup.kofa.interfaces import IKofaPluggable
[7811]23from waeup.kofa.university.interfaces import IFacultiesContainer, IFaculty
[10247]24from waeup.kofa.utils.batching import VirtualExportJobContainer
[3526]25
[10247]26class VirtualFacultiesExportJobContainer(VirtualExportJobContainer):
[10279]27    """A virtual export job container for the faculties container.
[10247]28    """
29
[7333]30class FacultiesContainer(grok.Container):
[4789]31    """See interfaces for description.
32    """
[7333]33    grok.implements(IFacultiesContainer)
[4789]34
[10247]35    def traverse(self, name):
36        if name == 'exports':
37            # create a virtual exports container and return it
38            container = VirtualFacultiesExportJobContainer()
39            zope.location.location.located(container, self, 'exports')
40            return container
41        return None
42
[4789]43    def addFaculty(self, faculty):
44        if not IFaculty.providedBy(faculty):
[7725]45            raise TypeError(
46                'FacultiesContainers contain only IFaculty instances')
[4789]47        self[faculty.code] = faculty
48        return
49
[7333]50class FacultiesContainerFactory(grok.GlobalUtility):
[4789]51    """A factory for faculty containers.
52    """
53    grok.implements(IFactory)
[7333]54    grok.name(u'waeup.FacultiesContainer')
55    title = u"Create a new facultiescontainer.",
56    description = u"This factory instantiates new containers for faculties."
[4789]57
[4976]58    def __call__(self, *args, **kw):
[7333]59        return FacultiesContainer(*args, **kw)
[4789]60
61    def getInterfaces(self):
[7333]62        return implementedBy(FacultiesContainer)
[5014]63
64class AcademicsPlugin(grok.GlobalUtility):
[7333]65    """A plugin that creates container for faculties inside a university.
[5014]66    """
[7819]67    grok.implements(IKofaPluggable)
[14511]68    grok.name('academics')
[5014]69
[5070]70    def setup(self, site, name, logger):
71        if 'faculties' in site.keys():
[7819]72            logger.warn('Could not create container for faculties in Kofa.')
[5070]73            return
[7333]74        site['faculties'] = FacultiesContainer()
75        logger.info('Container for faculties created')
[5070]76        return
[5014]77
[5070]78    def update(self, site, name, logger):
[6575]79        if not 'faculties' in site.keys():
80            self.setup(site, name, logger)
81
Note: See TracBrowser for help on using the repository browser.