source: main/waeup.kofa/trunk/src/waeup/kofa/university/vocabularies.py @ 12133

Last change on this file since 12133 was 11450, checked in by Henrik Bettermann, 11 years ago

Move ContextualDictSourceFactoryBase? to waeup.kofa.interfaces to avoid circular imports.

  • Property svn:keywords set to Id
File size: 3.8 KB
RevLine 
[7195]1## $Id: vocabularies.py 11450 2014-02-27 06:25:18Z 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##
[6091]18"""Vocabularies and sources for the academics section.
19"""
20from zc.sourcefactory.basic import BasicSourceFactory
[6557]21from zope.catalog.interfaces import ICatalog
[7916]22from zope.component import getUtility, queryUtility
[11450]23from waeup.kofa.interfaces import (
24    SimpleKofaVocabulary, IKofaUtils, ContextualDictSourceFactoryBase)
[7811]25from waeup.kofa.interfaces import MessageFactory as _
[8606]26from waeup.kofa.sourcefactory import SmartBasicContextualSourceFactory
[7916]27from waeup.kofa.utils.utils import KofaUtils
[6091]28
[7819]29course_levels = SimpleKofaVocabulary(
[7681]30    (_('Pre-Studies'),10),
31    (_('100 (Year 1)'),100),
32    (_('200 (Year 2)'),200),
33    (_('300 (Year 3)'),300),
34    (_('400 (Year 4)'),400),
35    (_('500 (Year 5)'),500),
36    (_('600 (Year 6)'),600),
37    (_('700 (Year 7)'),700),
38    (_('800 (Year 8)'),800),
[8084]39    (_('900 (Year 9)'),900),
[8471]40    (_('Postgraduate Level'),999),
[6091]41    )
42
[7916]43class SemesterSource(ContextualDictSourceFactoryBase):
[10436]44    """An institution type source delivers semester and/or term descriptors.
[7916]45    """
46    #: name of dict to deliver from kofa utils.
47    DICT_NAME = 'SEMESTER_DICT'
48
49class InstTypeSource(ContextualDictSourceFactoryBase):
50    """An institution type source delivers types of institutions
51    in the portal.
52    """
53    #: name of dict to deliver from kofa utils.
54    DICT_NAME = 'INST_TYPES_DICT'
55
56class AppCatSource(ContextualDictSourceFactoryBase):
[7681]57    """A application category source delivers all application categories
58    provided in the portal.
59    """
[7916]60    #: name of dict to deliver from kofa utils.
61    DICT_NAME = 'APP_CATS_DICT'
[7681]62
[7916]63class StudyModeSource(ContextualDictSourceFactoryBase):
[7681]64    """A study modes source delivers all study modes provided
65    in the portal.
66    """
[7916]67    #: name of dict to deliver from kofa utils.
68    DICT_NAME = 'STUDY_MODES_DICT'
[7681]69
[6091]70class CourseSource(BasicSourceFactory):
71    """A course source delivers all courses inside the portal by looking
72       up a catalog.
73    """
74    def getValues(self):
75        catalog = getUtility(ICatalog, name='courses_catalog')
[6092]76        return sorted(list(
77                catalog.searchResults(
[7916]78                    code=(None, None))),key=lambda value: value.code)
[6091]79
80    def getToken(self, value):
81        return value.code
82
83    def getTitle(self, value):
84        return "%s - %s" % (value.code, value.title[:64])
[7915]85
[8606]86
87
88class CertificateSource(SmartBasicContextualSourceFactory):
[7915]89    """A certificate source delivers all certificates provided
90    in the portal.
91    """
92    def getValues(self, context):
93        catalog = getUtility(ICatalog, name='certificates_catalog')
94        return sorted(list(
[7916]95            catalog.searchResults(
96                code=(None, None))),
97                      key=lambda value: value.code)
[7915]98
99    def getToken(self, context, value):
100        return value.code
101
102    def getTitle(self, context, value):
[8439]103        return "%s - %s" % (value.code, value.title)
[10831]104
105class SpecialApplicationSource(ContextualDictSourceFactoryBase):
106    """A special application source delivers all types of
107    applications which are not linked with certificates.
108    """
109    #: name of dict to deliver from kofa utils.
110    DICT_NAME = 'SPECIAL_APP_DICT'
Note: See TracBrowser for help on using the repository browser.