Changeset 6769 for main/waeup.sirp/trunk


Ignore:
Timestamp:
14 Sep 2011, 13:39:57 (13 years ago)
Author:
Henrik Bettermann
Message:

Implement RequestClearance? page. This is to avoid accidental clearance requests. Students have to reenter their CLR access code before the request is submitted.

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

Legend:

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

    r6767 r6769  
    177177            invalidate_accesscode(pin,comment)
    178178            IUserAccount(student).setPassword(self.ac_number)
     179            student.adm_code = pin
    179180        self.flash('Password has been set. Your Student Id is %s'
    180181            % self.student_id)
     
    668669        #    self.flash(self.dataNotComplete())
    669670        #    return
    670         state = IWorkflowState(self.context).getState()
    671         # This shouldn't happen, but the application officer
    672         # might have forgotten to lock the form after changing the state
    673         if state != CLEARANCE:
    674             self.flash('This form cannot be submitted. Wrong state!')
    675             return
    676         IWorkflowInfo(self.context).fireTransition('request_clearance')
    677         self.flash('Clearance has been requested.')
    678         self.redirect(self.url(self.context))
     671        self.redirect(self.url(self.context,'request_clearance'))
    679672        return
    680673
     
    687680    label = 'Start clearance'
    688681    ac_prefix = 'CLR'
    689     pnav = 4
    690     buttonname = 'Start'
     682    notice = ''
     683    pnav = 4
     684    buttonname = 'Start clearance now'
    691685
    692686    def update(self, SUBMIT=None):
     
    711705            # expect an exception
    712706            invalidate_accesscode(pin,comment)
     707            self.context.clr_code = pin
    713708        IWorkflowInfo(self.context).fireTransition('start_clearance')
    714709        self.flash('Clearance process is started.')
    715710        self.redirect(self.url(self.context,'cedit'))
    716711        return
     712
     713class RequestClearance(WAeUPPage):
     714    grok.context(IStudent)
     715    grok.name('request_clearance')
     716    grok.require('waeup.handleStudent')
     717    grok.template('enterpin')
     718    title = 'Request clearance'
     719    label = 'Request clearance'
     720    notice = 'Enter the CLR access code used for starting clearance.'
     721    ac_prefix = 'CLR'
     722    pnav = 4
     723    buttonname = 'Request clearance now'
     724
     725    def update(self, SUBMIT=None):
     726        self.ac_series = self.request.form.get('ac_series', None)
     727        self.ac_number = self.request.form.get('ac_number', None)
     728        if SUBMIT is None:
     729            return
     730        pin = '%s-%s-%s' % (self.ac_prefix, self.ac_series, self.ac_number)
     731        if self.context.clr_code != pin:
     732            self.flash("This isn't your CLR access code.")
     733            return
     734        state = IWorkflowState(self.context).getState()
     735        # This shouldn't happen, but the application officer
     736        # might have forgotten to lock the form after changing the state
     737        if state != CLEARANCE:
     738            self.flash('This form cannot be submitted. Wrong state!')
     739            return
     740        IWorkflowInfo(self.context).fireTransition('request_clearance')
     741        self.flash('Clearance has been requested.')
     742        self.redirect(self.url(self.context))
     743        return
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/enterpin.pt

    r6759 r6769  
    1111               value="" tal:attributes="value view/ac_series"/> -
    1212        <input name="ac_number" type="text" size="10" maxlength="10"
    13                value="" tal:attributes="value view/ac_number" /></td>
     13               value="" tal:attributes="value view/ac_number" />
     14        <font color="red"><span tal:replace="view/notice">Notice</span>
     15        </font>
     16        </td>
    1417      </tr>
    1518      <tr>
    1619        <td colspan="2">
    1720          <input type="submit" name="SUBMIT"
    18                  tal:attributes="value view/buttonname" /> </td>
     21                 tal:attributes="value view/buttonname" />
     22                 </td>
    1923      </tr>
    2024    </tbody>
  • main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py

    r6764 r6769  
    9191    state = Attribute('Returns the registration state of a student')
    9292    password = Attribute('Encrypted password of a student')
    93     adm_code = Attribute('Admission checking access code')
    9493
    9594    def loggerInfo(ob_class, comment):
     
    122121        )
    123122
     123    adm_code = schema.TextLine(
     124        title = u'PWD access code',
     125        default = u'',
     126        required = False,
     127        readonly = True,
     128        )
     129
    124130class IStudentClearance(IWAeUPObject):
    125131    """Representation of student clearance data.
     
    136142        )
    137143
     144    clr_code = schema.TextLine(
     145        title = u'CLR access code',
     146        default = u'',
     147        required = False,
     148        readonly = True,
     149        )
     150
    138151class IStudentPersonal(IWAeUPObject):
    139152    """Representation of student personal data.
  • main/waeup.sirp/trunk/src/waeup/sirp/students/student.py

    r6767 r6769  
    4747            self.student_id = u'Z654321'
    4848        self.password = None
    49         self.adm_code = None
    5049        return
    5150
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py

    r6767 r6769  
    401401        self.browser.getControl(name="ac_series").value = self.existing_clrseries
    402402        self.browser.getControl(name="ac_number").value = self.existing_clrnumber
    403         self.browser.getControl("Start").click()
     403        self.browser.getControl("Start clearance now").click()
    404404        self.assertMatches('...Clearance process is started...',
    405405                           self.browser.contents)
     
    411411        self.browser.getLink("Edit").click()
    412412        self.browser.getControl("Save and request clearance").click()
     413        self.browser.getControl(name="ac_series").value = self.existing_clrseries
     414        self.browser.getControl(name="ac_number").value = self.existing_clrnumber
     415        self.browser.getControl("Request clearance now").click()
    413416        self.assertMatches('...Clearance has been requested...',
    414417                           self.browser.contents)
Note: See TracChangeset for help on using the changeset viewer.