Changeset 9257


Ignore:
Timestamp:
28 Sep 2012, 19:47:52 (12 years ago)
Author:
Henrik Bettermann
Message:

Protect StudyLevelEditFormPage? and CourseTicketAddFormPage2. Students are not allowed to edit study levels which are not current.

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

    r9255 r9257  
    20022002            emit_lock_message(self)
    20032003            return
    2004         if self.context.student.state != PAID:
     2004        if self.context.student.state != PAID or \
     2005            not self.context.is_current_level:
    20052006            emit_lock_message(self)
    20062007            return
     
    20842085
    20852086    def update(self):
    2086         if self.context.student.state != PAID:
     2087        if self.context.student.state != PAID or \
     2088            not self.context.is_current_level:
    20872089            emit_lock_message(self)
    20882090            return
  • main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py

    r9253 r9257  
    430430    number_of_tickets = Attribute('Number of tickets contained in this level')
    431431    certcode = Attribute('The certificate code of the study course')
     432    is_current_level = Attribute('Is this level the current level of the student?')
    432433
    433434    level_session = schema.Choice(
  • main/waeup.kofa/trunk/src/waeup/kofa/students/studylevel.py

    r9253 r9257  
    5656    def number_of_tickets(self):
    5757        return len(self)
     58
     59    @property
     60    def is_current_level(self):
     61        try:
     62            return self.__parent__.current_level == self.level
     63        except AttributeError:
     64            return False
    5865
    5966    def writeLogMessage(self, view, message):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r9255 r9257  
    20632063                        'K1000000 - account activated' in logcontent)
    20642064
    2065     def test_student_transfer(self):
     2065    def test_student_locked_level_forms(self):
     2066
     2067        # Add two study levels, one current and one previous
     2068        studylevel = createObject(u'waeup.StudentStudyLevel')
     2069        studylevel.level = 100
     2070        self.student['studycourse'].addStudentStudyLevel(
     2071            self.certificate, studylevel)
     2072        studylevel = createObject(u'waeup.StudentStudyLevel')
     2073        studylevel.level = 200
     2074        self.student['studycourse'].addStudentStudyLevel(
     2075            self.certificate, studylevel)
     2076        IWorkflowState(self.student).setState('school fee paid')
     2077        self.student['studycourse'].current_level = 200
     2078
     2079        self.browser.open(self.login_path)
     2080        self.browser.getControl(name="form.login").value = self.student_id
     2081        self.browser.getControl(name="form.password").value = 'spwd'
     2082        self.browser.getControl("Login").click()
     2083
     2084        self.browser.open(self.student_path + '/studycourse/200/edit')
     2085        self.assertFalse('The requested form is locked' in self.browser.contents)
     2086        self.browser.open(self.student_path + '/studycourse/100/edit')
     2087        self.assertTrue('The requested form is locked' in self.browser.contents)
     2088
     2089        self.browser.open(self.student_path + '/studycourse/200/ctadd')
     2090        self.assertFalse('The requested form is locked' in self.browser.contents)
     2091        self.browser.open(self.student_path + '/studycourse/100/ctadd')
     2092        self.assertTrue('The requested form is locked' in self.browser.contents)
     2093
     2094        IWorkflowState(self.student).setState('courses registered')
     2095        self.browser.open(self.student_path + '/studycourse/200/edit')
     2096        self.assertTrue('The requested form is locked' in self.browser.contents)
     2097        self.browser.open(self.student_path + '/studycourse/200/ctadd')
     2098        self.assertTrue('The requested form is locked' in self.browser.contents)
     2099
     2100
     2101    def test_manage_student_transfer(self):
    20662102        # Add second certificate
    20672103        self.certificate2 = createObject('waeup.Certificate')
     
    20762112        studylevel = createObject(u'waeup.StudentStudyLevel')
    20772113        studylevel.level = 200
     2114        self.student['studycourse'].addStudentStudyLevel(
     2115            self.certificate, studylevel)
     2116        studylevel = createObject(u'waeup.StudentStudyLevel')
     2117        studylevel.level = 999
    20782118        self.student['studycourse'].addStudentStudyLevel(
    20792119            self.certificate, studylevel)
     
    21042144        # Add study level to new study course
    21052145        studylevel = createObject(u'waeup.StudentStudyLevel')
    2106         studylevel.level = 200
     2146        studylevel.level = 999
    21072147        self.student['studycourse'].addStudentStudyLevel(
    21082148            self.certificate, studylevel)
     
    21252165        self.assertTrue('The requested form is locked' in self.browser.contents)
    21262166
    2127         self.browser.open(self.student_path + '/studycourse/200/manage')
     2167        self.browser.open(self.student_path + '/studycourse/999/manage')
    21282168        self.assertFalse('The requested form is locked' in self.browser.contents)
    2129         self.browser.open(self.student_path + '/studycourse_1/200/manage')
     2169        self.browser.open(self.student_path + '/studycourse_1/999/manage')
    21302170        self.assertTrue('The requested form is locked' in self.browser.contents)
    21312171
    2132         self.browser.open(self.student_path + '/studycourse/200/validate_courses')
     2172        self.browser.open(self.student_path + '/studycourse/999/validate_courses')
    21332173        self.assertFalse('The requested form is locked' in self.browser.contents)
    2134         self.browser.open(self.student_path + '/studycourse_1/200/validate_courses')
     2174        self.browser.open(self.student_path + '/studycourse_1/999/validate_courses')
    21352175        self.assertTrue('The requested form is locked' in self.browser.contents)
    21362176
    2137         self.browser.open(self.student_path + '/studycourse/200/reject_courses')
     2177        self.browser.open(self.student_path + '/studycourse/999/reject_courses')
    21382178        self.assertFalse('The requested form is locked' in self.browser.contents)
    2139         self.browser.open(self.student_path + '/studycourse_1/200/reject_courses')
     2179        self.browser.open(self.student_path + '/studycourse_1/999/reject_courses')
    21402180        self.assertTrue('The requested form is locked' in self.browser.contents)
    21412181
    2142         self.browser.open(self.student_path + '/studycourse/200/add')
     2182        self.browser.open(self.student_path + '/studycourse/999/add')
    21432183        self.assertFalse('The requested form is locked' in self.browser.contents)
    2144         self.browser.open(self.student_path + '/studycourse_1/200/add')
     2184        self.browser.open(self.student_path + '/studycourse_1/999/add')
    21452185        self.assertTrue('The requested form is locked' in self.browser.contents)
    21462186
    2147         self.browser.open(self.student_path + '/studycourse/200/edit')
     2187        self.browser.open(self.student_path + '/studycourse/999/edit')
    21482188        self.assertFalse('The requested form is locked' in self.browser.contents)
    2149         self.browser.open(self.student_path + '/studycourse_1/200/edit')
     2189        self.browser.open(self.student_path + '/studycourse_1/999/edit')
    21502190        self.assertTrue('The requested form is locked' in self.browser.contents)
    21512191
  • main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py

    r9237 r9257  
    565565    def target_url(self):
    566566        student = self.view.context.student
    567         condition1 = student.state != PAID
    568         condition2 = student[
    569             'studycourse'].current_level != self.view.context.level
     567        condition1 = student.state == PAID
     568        condition2 = self.view.context.is_current_level
    570569        is_current = self.context.__parent__.is_current
    571         if condition1 or condition2 or not is_current:
    572             return ''
    573         return self.view.url(self.view.context, self.target)
     570        if condition1 and condition2 and is_current:
     571            return self.view.url(self.view.context, self.target)
     572        return ''
    574573
    575574class StudentsTab(PrimaryNavTab):
Note: See TracChangeset for help on using the changeset viewer.