## $Id: studylevel.py 7191 2011-11-25 07:13:22Z 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 ## """ Container which holds the data of a student study level and contains the course tickets. """ import grok from grok import index from zope.component.interfaces import IFactory from waeup.sirp.students.interfaces import ( IStudentStudyLevel, IStudentNavigation, ICourseTicket) from waeup.sirp.utils.helpers import attrs_to_fields from waeup.sirp.students.vocabularies import StudyLevelSource class StudentStudyLevel(grok.Container): """This is a container for course tickets. """ grok.implements(IStudentStudyLevel, IStudentNavigation) grok.provides(IStudentStudyLevel) def __init__(self): super(StudentStudyLevel, self).__init__() self.level = None self.validation_date = None self.validated_by = None return def getStudent(self): return self.__parent__.__parent__ @property def level_title(self): studylevelsource = StudyLevelSource() return studylevelsource.factory.getTitle(self.__parent__, self.level) def addCourseTicket(self, courseticket): """Add a course ticket object. """ if not ICourseTicket.providedBy(courseticket): raise TypeError( 'StudentStudyLeves contain only ICourseTicket instances') self[courseticket.code] = courseticket return StudentStudyLevel = attrs_to_fields(StudentStudyLevel) class CourseTicket(grok.Model): """This is a course ticket which allows the student to attend the course. Lecturers will enter scores and more at the end of the term. A course ticket contains a copy of the original course and course referrer data. If the courses and/or their referrers are removed, the corresponding tickets remain unchanged. So we do not need any event triggered actions on course tickets. """ grok.implements(ICourseTicket, IStudentNavigation) grok.provides(ICourseTicket) def __init__(self): super(CourseTicket, self).__init__() self.code = None self.title = None self.faculty = None self.department = None self.credits = None self.passmark = None self.semester = None return def getStudent(self): return self.__parent__.__parent__.__parent__ CourseTicket = attrs_to_fields(CourseTicket)