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

Add property is_postgrad.

Add invariant constraint to ICertificate.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/students
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r8471 r8472  
    412412    @property
    413413    def form_fields(self):
    414         cm = getattr(self.context,'current_mode', None)
    415         if cm is not None and cm.startswith('pg'):
     414        if self.context.is_postgrad:
    416415            form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked')
    417416        else:
     
    434433    @property
    435434    def form_fields(self):
    436         cm = getattr(self.context,'current_mode', None)
    437         if cm is not None and cm.startswith('pg'):
     435        if self.context.is_postgrad:
    438436            form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked')
    439437        else:
     
    478476    @property
    479477    def form_fields(self):
    480         cm = getattr(self.context,'current_mode', None)
    481         if cm is not None and cm.startswith('pg'):
     478        if self.context.is_postgrad:
    482479            form_fields = grok.AutoFields(IPGStudentClearance)
    483480        else:
     
    16211618    @property
    16221619    def form_fields(self):
    1623         cm = getattr(self.context,'current_mode', None)
    1624         if cm is not None and cm.startswith('pg'):
     1620        if self.context.is_postgrad:
    16251621            form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked')
    16261622        else:
  • main/waeup.kofa/trunk/src/waeup/kofa/students/student.py

    r8452 r8472  
    133133        if certificate is not None:
    134134            return certificate.study_mode
    135         return
     135        return None
     136
     137    @property
     138    def is_postgrad(self):
     139        is_postgrad = getattr(
     140            self.get('studycourse', None), 'is_postgrad', False)
     141        return is_postgrad
    136142
    137143# Set all attributes of Student required in IStudent as field
  • main/waeup.kofa/trunk/src/waeup/kofa/students/studycourse.py

    r8471 r8472  
    4848            return True
    4949        if self.getStudent().state == PAID \
    50             and self.getStudent().current_mode.startswith('pg'):
     50            and self.getStudent().is_postgrad:
    5151            return True
    5252        return False
     
    105105        return
    106106
     107    @property
     108    def is_postgrad(self):
     109        cert = getattr(self, 'certificate', None)
     110        if cert is not None:
     111            return cert.study_mode.startswith('pg')
     112            #return cert.start_level == 999 or cert.end_level == 999
     113        return False
     114
    107115StudentStudyCourse = attrs_to_fields(StudentStudyCourse)
    108116
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r8471 r8472  
    18371837        self.assertFalse('Employer' in self.browser.contents)
    18381838        # Now we change the study mode of the certificate and a different
    1839         # interface is used by clearance views
     1839        # interface is used by clearance views.
    18401840        self.certificate.study_mode = 'pg_ft'
     1841        # Invariants are not being checked here?!
     1842        self.certificate.end_level = 100
    18411843        self.browser.open(self.clearance_path)
    18421844        self.assertTrue('Employer' in self.browser.contents)
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r8471 r8472  
    278278                details['p_session'], details[
    279279                    'p_level'] = self.getReturningData(student)
    280             elif student.current_mode.startswith('pg') and student.state == PAID:
     280            elif student.is_postgrad and student.state == PAID:
    281281                # Returning postgraduate students also pay for the next session
    282282                # but their level always remains the same.
Note: See TracChangeset for help on using the changeset viewer.