Changeset 4321


Ignore:
Timestamp:
20 Jun 2009, 19:22:48 (16 years ago)
Author:
uli
Message:

Add implementations for certificate courses.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup/branches/ulif-rewrite/src/waeup/university/certificate.py

    r4318 r4321  
    44from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
    55from zope.component.interfaces import IFactory
    6 from waeup.interfaces import ICertificate, ICertificateContainer
     6from waeup.interfaces import (ICertificate, ICertificateContainer,
     7                              ICertificateCourse)
    78
    89class Certificate(grok.Container):
     
    2829
    2930    def check(self):
     31        """Set Review State to ``checked``.
     32        """
    3033        self.setReviewState('check')
    3134
     
    3639        info = IWorkflowInfo(self)
    3740        info.fireTransition(transition_id)
     41        return
     42
     43    def addCourseRef(self, course, level=100, core_or_elective=True):
     44        """Add a course reference.
     45        """
     46        code = course.code
     47        self[code] = CertificateCourse(course, level, core_or_elective)
     48
     49    def delCourseRef(self, code):
     50        """Delete a course denoted by its code.
     51        """
     52        if code in self.keys():
     53            del self[code]
     54            self._p_changed = True
    3855        return
    3956
     
    5471    def getInterfaces(self):
    5572        return implementedBy(Certificate)
     73
     74class CertificateCourse(grok.Model):
     75    grok.implements(ICertificateCourse)
     76
     77    def __init__(self, course=None, level=100, core_or_elective=True):
     78        # XXX Make sure, this reference is deleted, when the course
     79        # does not exist anymore (or the referenced course will still
     80        # exist here).
     81        self.course = course
     82        self.level = level
     83        self.core_or_elective = core_or_elective
Note: See TracChangeset for help on using the changeset viewer.