Ignore:
Timestamp:
20 May 2012, 09:57:09 (13 years ago)
Author:
Henrik Bettermann
Message:

Add property is_postgrad.

Add invariant constraint to ICertificate.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/university/interfaces.py

    r8299 r8472  
    2020
    2121from zope import schema
    22 from zope.interface import Attribute
     22from zope.interface import Attribute, invariant, Invalid
    2323from waeup.kofa.interfaces import (IKofaObject, IKofaContainer)
    2424from waeup.kofa.interfaces import MessageFactory as _
     
    245245        """
    246246
     247    @invariant
     248    def check_pg_conditions(cert):
     249        if cert.start_level == 999 and not cert.end_level == 999:
     250            raise Invalid(_("Start level and end level must correspond."))
     251        if cert.end_level == 999 and not cert.start_level == 999:
     252            raise Invalid(_("Start level and end level must correspond."))
     253        if cert.study_mode.startswith('pg') and not cert.start_level == 999:
     254            raise Invalid(_(
     255                "Study mode, start level and end level must correspond."))
     256        if cert.start_level == 999  and not cert.study_mode.startswith('pg'):
     257            raise Invalid(_(
     258                "Study mode, start level and end level must correspond."))
     259
     260
    247261class ICertificateAdd(ICertificate):
    248262    """Representation of a certificate.
Note: See TracChangeset for help on using the changeset viewer.