Ignore:
Timestamp:
13 Apr 2015, 14:55:28 (10 years ago)
Author:
Henrik Bettermann
Message:

Students are only allowed to download course registration slips if they are
in state 'registered' and their current level corresponds with the course
registration level.

Location:
main/waeup.uniben/trunk/src/waeup/uniben/students
Files:
3 edited

Legend:

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

    r12852 r12855  
    255255        'level_verdict', 'gpa')
    256256
     257    def update(self):
     258        if self.context.student.state != REGISTERED \
     259            or self.context.student.current_level != self.context.level:
     260            self.flash(_('Forbidden'), type="warning")
     261            self.redirect(self.url(self.context))
     262
    257263    @property
    258264    def tabletitle(self):
  • main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py

    r12846 r12855  
    366366        self.browser.getLink("COURSE1").click()
    367367        self.assertFalse('Score' in self.browser.contents)
    368         # Students can open the customized pdf course registration slip
    369         self.browser.open(self.student_path + '/studycourse/100')
    370         self.browser.getLink("Download course registration slip").click()
    371         self.assertEqual(self.browser.headers['Status'], '200 Ok')
    372         self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
    373368        # Students can open the special Uniben pdf course result slip
    374369        self.browser.open(self.student_path + '/studycourse/100')
     
    384379        self.browser.getControl("Remove selected", index=0).click()
    385380        self.assertTrue('Successfully removed' in self.browser.contents)
     381        # Students can open the customized pdf course registration slip
     382        # if they have registered their course list
     383        self.browser.open(
     384            self.student_path + '/studycourse/100/course_registration_slip.pdf')
     385        self.assertTrue('Forbidden' in self.browser.contents)
     386        IWorkflowState(self.student).setState('courses registered')
     387        self.browser.open(self.student_path + '/studycourse/100')
     388        self.browser.getLink("Download course registration slip").click()
     389        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     390        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
    386391
    387392    def test_get_returning_data(self):
  • main/waeup.uniben/trunk/src/waeup/uniben/students/viewlets.py

    r12452 r12855  
    1818
    1919import grok
    20 from waeup.kofa.interfaces import REQUESTED
     20from waeup.kofa.interfaces import REQUESTED, REGISTERED
    2121from waeup.kofa.browser.viewlets import ManageActionButton
    2222from waeup.uniben.students.interfaces import (
     
    4444            return self.view.url(self.view.context, self.target)
    4545        return False
     46
     47class CourseRegistrationSlipActionButton(ManageActionButton):
     48    grok.order(5)
     49    grok.context(ICustomStudentStudyLevel)
     50    grok.view(StudyLevelDisplayFormPage)
     51    grok.require('waeup.viewStudent')
     52    icon = 'actionicon_pdf.png'
     53    text = _('Download course registration slip')
     54    target = 'course_registration_slip.pdf'
     55
     56    @property
     57    def target_url(self):
     58        is_current = self.context.__parent__.is_current
     59        if not is_current:
     60            return ''
     61        if self.context.student.state != REGISTERED \
     62            or self.context.student.current_level != self.context.level:
     63            return ''
     64        return self.view.url(self.view.context, self.target)
    4665
    4766class CourseResultSlipActionButton(ManageActionButton):
Note: See TracChangeset for help on using the changeset viewer.