Changeset 6781 for main/waeup.sirp/trunk


Ignore:
Timestamp:
16 Sep 2011, 08:26:25 (13 years ago)
Author:
Henrik Bettermann
Message:

Add CourseTicket? class.

  • work in progress -
Location:
main/waeup.sirp/trunk/src/waeup/sirp/students
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py

    r6775 r6781  
    207207    """
    208208    level = Attribute('The level code')
    209     level_title = Attribute('Title of level')
     209
     210
     211class ICourseTicket(IWAeUPObject):
     212    """A course ticket.
     213
     214    """
     215    code = Attribute('Course code')
     216    title = Attribute('Course title')
     217    course_level = Attribute('level of the original course referrer')
     218    core_or_elective = Attribute('core_or_elective of the original course referrer')
     219
     220    credits = schema.Int(
     221        title = u'Credits',
     222        default = 0,
     223        required = False,
     224        readonly = False,
     225        )
     226
     227    score = schema.Int(
     228        title = u'Score',
     229        default = 0,
     230        required = False,
     231        readonly = False,
     232        )
     233
     234    grade = schema.TextLine(
     235        title = u'Grade',
     236        default = u'',
     237        required = False,
     238        readonly = True,
     239        )
    210240
    211241class IStudentAccommodation(IWAeUPObject):
  • main/waeup.sirp/trunk/src/waeup/sirp/students/studylevel.py

    r6775 r6781  
    2222from zope.component.interfaces import IFactory
    2323from waeup.sirp.students.interfaces import (
    24     IStudentStudyLevel, IStudentNavigation)
     24    IStudentStudyLevel, IStudentNavigation, ICourseTicket)
    2525from waeup.sirp.utils.helpers import attrs_to_fields
    2626from waeup.sirp.students.vocabularies import StudyLevelSource
     
    4545        return studylevelsource.factory.getTitle(self.__parent__, self.level)
    4646
     47    def addCourseTicket(self, courseticket):
     48        """Add a course ticket object.
     49        """
     50        if not ICourseTicket.providedBy(courseticket):
     51            raise TypeError(
     52                'StudentStudyLeves contain only ICourseTicket instances')
     53        self[str(courseticket.code)] = courseticket
     54        return
     55
    4756StudentStudyLevel = attrs_to_fields(StudentStudyLevel)
     57
     58class CourseTicket(grok.Model):
     59    """This is a course ticket which allows the
     60    student to attend the course. Lecturers will enter scores and more at
     61    the end of the term.
     62    """
     63    grok.implements(ICourseTicket, IStudentNavigation)
     64    grok.provides(ICourseTicket)
     65
     66    def __init__(self, code, title, course_level, core_or_elective):
     67        super(CourseTicket, self).__init__()
     68        self.title = title
     69        self.code = code
     70        self.course_level = course_level
     71        self.core_or_elective = core_or_elective
     72        return
     73
     74    def getStudent(self):
     75        return self.__parent__.__parent__.__parent__
     76
     77CourseTicket = attrs_to_fields(CourseTicket)
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_student.py

    r6752 r6781  
    2020from waeup.sirp.students.student import Student, StudentFactory
    2121from waeup.sirp.students.studycourse import StudentStudyCourse
     22from waeup.sirp.students.studylevel import StudentStudyLevel, CourseTicket
    2223from waeup.sirp.students.payments import StudentPayments
    2324from waeup.sirp.students.accommodation import StudentAccommodation
    2425from waeup.sirp.students.interfaces import (
    2526    IStudent, IStudentStudyCourse, IStudentPayments, IStudentAccommodation,
    26     )
     27    IStudentStudyLevel, ICourseTicket)
    2728from waeup.sirp.testing import FunctionalLayer, FunctionalTestCase
    2829
     
    3536        self.student = Student()
    3637        self.studycourse = StudentStudyCourse()
     38        self.studylevel = StudentStudyLevel()
     39        self.courseticket = CourseTicket('CERT', 'Title', 100, True)
    3740        self.payments = StudentPayments()
    3841        self.accommodation = StudentAccommodation()
     
    4851        verify.verifyClass(IStudentStudyCourse, StudentStudyCourse)
    4952        verify.verifyObject(IStudentStudyCourse, self.studycourse)
     53        verify.verifyObject(IStudentStudyLevel, self.studylevel)
     54        verify.verifyObject(ICourseTicket, self.courseticket)
    5055        verify.verifyClass(IStudentPayments, StudentPayments)
    5156        verify.verifyObject(IStudentPayments, self.payments)
Note: See TracChangeset for help on using the changeset viewer.