## $Id: vocabularies.py 7321 2011-12-10 06:15:17Z henrik $
##
## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##
"""Vocabularies and sources for the academics section.
"""
from zc.sourcefactory.basic import BasicSourceFactory
from zope.catalog.interfaces import ICatalog
from zope.component import getUtility
from waeup.sirp.interfaces import SimpleSIRPVocabulary

inst_types = SimpleSIRPVocabulary(
    ('Faculty of','faculty'),
    ('Department of','department'),
    ('School of','school'),
    ('School for','school_for'),
    ('Institute of','institute'),
    ('Office for','office'),
    ('Centre for','centre'),
    ('College','college'),
    )

course_levels = SimpleSIRPVocabulary(
    ('Pre-Studies',0),
    ('100 (Year 1)',100),
    ('200 (Year 2)',200),
    ('300 (Year 3)',300),
    ('400 (Year 4)',400),
    ('500 (Year 5)',500),
    ('600 (Year 6)',600),
    ('700 (Year 7)',700),
    ('800 (Year 8)',800),
    )

semester = SimpleSIRPVocabulary(
    ('N/A', 0),
    ('First Semester', 1),
    ('Second Semester', 2),
    ('Combined', 3)
    )

application_categories = SimpleSIRPVocabulary(
    ('PUME, PDE, PCE, PRENCE','basic'),
    ('Part-Time, Diploma, Certificate','cest'),
    ('Sandwich','sandwich'),
    ('Postgraduate','pg'),
    )

study_modes = SimpleSIRPVocabulary(
    ('UME Full Time','ume_ft'),
    ('Direct Entry Full Time','de_ft'),
    ('Diploma Full Time','dp_ft'),
    ('Diploma Part Time','dp_pt'),
    ('Undergraduate Full Time','ug_ft'),
    ('Undergraduate Part Time','ug_pt'),
    ('Postgraduate Full Time','pg_ft'),
    ('Postgraduate Part Time','pg_pt'),
    )


class CourseSource(BasicSourceFactory):
    """A course source delivers all courses inside the portal by looking
       up a catalog.
    """
    def getValues(self):
        catalog = getUtility(ICatalog, name='courses_catalog')
        return sorted(list(
                catalog.searchResults(
                    code=('', 'z*'))),key=lambda value: value.code)

    def getToken(self, value):
        return value.code

    def getTitle(self, value):
        return "%s - %s" % (value.code, value.title[:64])
