Changeset 9814


Ignore:
Timestamp:
21 Dec 2012, 08:51:44 (12 years ago)
Author:
Henrik Bettermann
Message:

Add clearance_enabled field to ISessionConfiguration. Clearance can now be disabled for certain sessions via this switch.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
4 edited

Legend:

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

    r9797 r9814  
    631631        )
    632632
     633    clearance_enabled = schema.Bool(
     634        title = _(u'Clearance enabled'),
     635        default = False,
     636        )
     637
    633638    def getSessionString():
    634639        """Returns the session string from the vocabulary.
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r9813 r9814  
    126126        yield value_dict
    127127
     128def clearance_disabled_message(student):
     129    try:
     130        session_config = grok.getSite()[
     131            'configuration'][str(student.current_session)]
     132    except KeyError:
     133        return _('Session configuration object is not available.')
     134    if not session_config.clearance_enabled:
     135        return _('Clearance is disabled for this session.')
     136    return None
     137
    128138class StudentsBreadcrumb(Breadcrumb):
    129139    """A breadcrumb for the students container.
     
    724734
    725735    def update(self):
     736        if clearance_disabled_message(self.context):
     737            self.flash(clearance_disabled_message(self.context))
     738            self.redirect(self.url(self.context,'view_clearance'))
     739            return
    726740        if self.context.state == REQUESTED:
    727741            IWorkflowInfo(self.context).fireTransition('clear')
     
    744758    form_fields = grok.AutoFields(
    745759        IUGStudentClearance).select('officer_comment')
     760
     761    def update(self):
     762        if clearance_disabled_message(self.context):
     763            self.flash(clearance_disabled_message(self.context))
     764            self.redirect(self.url(self.context,'view_clearance'))
     765            return
     766        return super(StudentRejectClearancePage, self).update()
    746767
    747768    @action(_('Save comment and reject clearance now'), style='primary')
     
    771792        return
    772793
    773     #def render(self):
    774     #    return
    775794
    776795class StudentPersonalDisplayFormPage(KofaDisplayFormPage):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r9812 r9814  
    12671267        self.assertRaises(
    12681268            Unauthorized, self.browser.open, other_student_path)
     1269        # Clearance is disabled for this session
     1270        self.browser.open(self.clearance_path)
     1271        self.assertFalse('Clear student' in self.browser.contents)
     1272        self.browser.open(self.student_path + '/clear')
     1273        self.assertTrue('Clearance is disabled for this session'
     1274            in self.browser.contents)
     1275        self.app['configuration']['2004'].clearance_enabled = True
    12691276        # Only in state clearance requested the CO does see the 'Clear' button
    12701277        self.browser.open(self.clearance_path)
  • main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py

    r9521 r9814  
    3535    VALIDATED)
    3636from waeup.kofa.students.browser import (
     37    clearance_disabled_message,
    3738    StudentClearanceManageFormPage,
    3839    StudentBaseManageFormPage, StudentFilesUploadPage,
     
    263264    @property
    264265    def target_url(self):
     266        if clearance_disabled_message(self.context):
     267            return ''
    265268        if self.context.state != REQUESTED:
    266269            return ''
     
    278281    @property
    279282    def target_url(self):
     283        if clearance_disabled_message(self.context):
     284            return ''
    280285        if self.context.state not in (REQUESTED, CLEARED):
    281286            return ''
Note: See TracChangeset for help on using the changeset viewer.