## $Id: interfaces.py 7819 2012-03-08 22:28:46Z 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 ## """Interfaces of academics specific objects. """ from zope import schema from zope.interface import Attribute from waeup.kofa.interfaces import (IKofaObject, IKofaContainer) from waeup.kofa.interfaces import MessageFactory as _ from waeup.kofa.university.vocabularies import ( course_levels, CourseSource, StudyModeSource, AppCatSource, InstTypeSource, SemesterSource, ) class IFaculty(IKofaContainer): """Representation of a university faculty. """ code = schema.TextLine( title = _(u'Code'), default = u'NA', required = True, readonly = True, ) title = schema.TextLine( title = _(u'Name of faculty'), default = _(u'Unnamed'), required = True, ) title_prefix = schema.Choice( title = _(u'Name prefix'), default = u'faculty', source = InstTypeSource(), required = True, ) def longtitle(): """ Returns the long title of a faculty. """ class IFacultyAdd(IFaculty): """Representation of a university faculty. """ code = schema.TextLine( title = _(u'Code'), description = _(u'This code will become part of the URL.'), default = u'NA', required = True, readonly = False, ) IFacultyAdd['code'].order = IFaculty['code'].order class IFacultiesContainer(IKofaContainer): """A container for faculties. """ def addFaculty(faculty): """Add an IFactulty object. """ class IDepartment(IKofaObject): """Representation of a department. """ code = schema.TextLine( title = _(u'Code'), default = u'NA', required = True, readonly = True, ) title = schema.TextLine( title = _(u'Name of department'), default = _(u'Unnamed'), required = True, ) title_prefix = schema.Choice( title = _(u'Name prefix'), source = InstTypeSource(), default = u'department', required = True, ) courses = Attribute("A container for courses.") certificates = Attribute("A container for certificates.") def longtitle(): """ Returns the long title of a department. """ class IDepartmentAdd(IDepartment): """Representation of a university department. """ code = schema.TextLine( title = _(u'Code'), description = _(u'This code will become part of the URL.'), default = u'NA', required = True, readonly = False, ) IDepartmentAdd['code'].order = IDepartment['code'].order class ICoursesContainer(IKofaContainer): """A container for faculties. """ def addCourse(course): """Add an ICourse object. Returns the key, under which the object was stored. """ class ICourse(IKofaObject): """Representation of a course. """ code = schema.TextLine( title = _(u'Code'), default = u'NA', required = True, readonly = True, ) title = schema.TextLine( title = _(u'Title of course'), default = _(u'Unnamed'), required = True, ) credits = schema.Int( title = _(u'Credits'), default = 0, required = False, ) passmark = schema.Int( title = _(u'Passmark'), default = 40, required = False, ) semester = schema.Choice( title = _(u'Semester/Term'), default = 9, source = SemesterSource(), required = True, ) def longtitle(): """ Returns the long title of a course. """ class ICourseAdd(ICourse): """Representation of a course. """ code = schema.TextLine( title = _(u'Code'), description = _(u'Enter unique course code which will become part of the URL.'), default = u'NA', required = True, readonly = False, ) ICourseAdd['code'].order = ICourse['code'].order class ICertificate(IKofaObject): """Representation of a certificate. """ code = schema.TextLine( title = _(u'Code'), default = u'NA', required = True, readonly = True, ) title = schema.TextLine( title = _(u'Title'), default = _(u'Unnamed'), required = True, ) study_mode = schema.Choice( title = _(u'Study Mode'), source = StudyModeSource(), default = u'ug_ft', required = True, ) start_level = schema.Choice( title = _(u'Start Level'), vocabulary = course_levels, default = 100, required = True, ) end_level = schema.Choice( title = _(u'End Level'), vocabulary = course_levels, default = 500, required = True, ) application_category = schema.Choice( title = _(u'Application Category'), source = AppCatSource(), default = u'basic', required = True, ) def longtitle(): """ Returns the long title of a certificate. """ class ICertificateAdd(ICertificate): """Representation of a certificate. """ code = schema.TextLine( title = _(u'Code'), default = u'NA', description = _(u'Enter unique certificate code which will become part of the URL.'), required = True, readonly = False, ) ICertificateAdd['code'].order = ICertificate['code'].order class ICertificatesContainer(IKofaContainer): """A container for certificates. """ def addCertificate(certificate): """Add an ICertificate object. Returns the key, under which the object was stored. """ class ICertificateCourse(IKofaObject): """A certificatecourse is referring a course and provides some own attributes. """ course = schema.Choice( title = _(u'Course Referrer'), source = CourseSource(), readonly = True, ) level = schema.Choice( title = _(u'Level'), required = True, vocabulary = course_levels, readonly = False, ) mandatory = schema.Bool( title = _(u'Is mandatory course (not elective)'), required = True, default = True, ) def getCourseCode(): """Return the code of the course referred to. This is needed for cataloging. """ def longtitle(): """ Returns the long title of a certificatecourse. """ class ICertificateCourseAdd(ICertificateCourse): """A certificatecourse is referring a course and provides some own attributes. """ course = schema.Choice( title = _(u'Course'), source = CourseSource(), readonly = False, ) ICertificateCourseAdd['course'].order = ICertificateCourse['course'].order