source: main/waeup.sirp/trunk/src/waeup/sirp/university/facultycontainer.py @ 5447

Last change on this file since 5447 was 5070, checked in by uli, 15 years ago

Update faculty container plugin.

  • Property svn:eol-style set to native
File size: 1.9 KB
RevLine 
[3526]1import grok
[4789]2from zope.component.interfaces import IFactory
3from zope.interface import implementedBy
[5014]4from waeup.sirp.interfaces import IWAeUPSIRPPluggable
[5005]5from waeup.sirp.university.interfaces import IFacultyContainer, IFaculty
[3526]6
[4789]7class FacultyContainer(grok.Container):
8    """See interfaces for description.
9    """
10    grok.implements(IFacultyContainer)
11    grok.require('waeup.manageUniversity')
12
13    def addFaculty(self, faculty):
14        if not IFaculty.providedBy(faculty):
15            raise TypeError('FacultyContainers contain only IFaculty instances')
16        self[faculty.code] = faculty
17        return
18
19    def clear(self):
20        keys = self.keys()
21        for key in keys:
22            del self[key]
23
24    def getName(self, key):
25        if key in self.keys():
26            fac = self[key]
27            prefix = fac.title_prefix
28            prefix = prefix[0].upper() + prefix[1:]
29            return '%s of %s' % (prefix, fac.title)
30           
31class FacultyContainerFactory(grok.GlobalUtility):
32    """A factory for faculty containers.
33    """
34    grok.implements(IFactory)
35    grok.name(u'waeup.FacultyContainer')
36    title = u"Create a new faculty container.",
37    description = u"This factory instantiates new faculty containers."
38
[4976]39    def __call__(self, *args, **kw):
40        return FacultyContainer(*args, **kw)
[4789]41
42    def getInterfaces(self):
43        return implementedBy(FacultyContainer)
[5014]44
45class AcademicsPlugin(grok.GlobalUtility):
[5070]46    """A plugin that creates a faculty container inside a university.
[5014]47    """
48    grok.implements(IWAeUPSIRPPluggable)
[5070]49    grok.name('faculties')
[5014]50
[5070]51    def setup(self, site, name, logger):
52        if 'faculties' in site.keys():
53            logger.warn('Could not create faculty container in WAeUP SIRP.')
54            return
55        site['faculties'] = FacultyContainer()
56        logger.info('Created faculty container for University')
57        return
[5014]58
[5070]59    def update(self, site, name, logger):
60        pass
Note: See TracBrowser for help on using the repository browser.