Ignore:
Timestamp:
8 Sep 2021, 07:15:07 (3 years ago)
Author:
Henrik Bettermann
Message:

Enable students and officers to upload scanned signature in the same
way as passport pictures are handled. Some tabs and titles had to be
renamed. The placeholder file, which is still the portrait
placeholder, are no longer shown on base pages.

Location:
main/waeup.kofa/trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk

    • Property svn:ignore
      •  

        old new  
        2121faculties.csv
        2222.mr.developer.cfg
         23dist
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r16520 r16609  
    29242924
    29252925class StudentFilesUploadPage(KofaPage):
    2926     """ View to upload files by student
     2926    """ View to upload passport picture by student. The class name
     2927    is historical. The page is only used for the student's portrait.
    29272928    """
    29282929    grok.context(IStudent)
     
    29402941            return
    29412942        super(StudentFilesUploadPage, self).update()
     2943        return
     2944
     2945class StudentSignatureUploadPage(KofaPage):
     2946    """ View to upload scanned signature by student. Not active
     2947    in base package.
     2948    """
     2949    grok.context(IStudent)
     2950    grok.name('change_signature')
     2951    grok.require('waeup.uploadStudentFile')
     2952    grok.template('filesuploadpage')
     2953    label = _('Upload signature')
     2954    pnav = 4
     2955
     2956    def update(self):
     2957        SIGNATURE_CHANGE_STATES = getUtility(IStudentsUtils).SIGNATURE_CHANGE_STATES
     2958        if self.context.student.state not in SIGNATURE_CHANGE_STATES:
     2959            emit_lock_message(self,
     2960                _('This form is locked. You are in the wrong state.'))
     2961            return
     2962        super(StudentSignatureUploadPage, self).update()
    29422963        return
    29432964
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser_templates/basemanagepage.pt

    r11254 r16609  
    1010    <li>
    1111      <a href="#tab2" data-toggle="tab">
    12         <span i18n:translate="">Passport Picture</span>
     12        <span i18n:translate="">Files</span>
    1313      </a>
    1414    </li>
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser_templates/imagedisplay.pt

    r11254 r16609  
    1 <tr>
     1<tr tal:condition="viewlet/file_exists">
    22  <td class="fieldname">
    33        <span tal:replace="viewlet/label">FILENAME</span>:
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser_templates/imageupload.pt

    r11558 r16609  
    44  </td>
    55  <td>
    6     <img align="middle" height="125px"
    7          tal:attributes="src python: view.url(context, viewlet.download_name)" />
    8     &nbsp;
    9     <input type="submit" tal:condition="viewlet/file_exists"
    10      tal:attributes="id python:('delete_%s' % viewlet.input_name);
    11         name python:('delete_%s' % viewlet.input_name)"
    12      value="Delete" class="btn btn-danger" />
    13     <br /><br />
    14 
     6    <tal:file_exists condition="viewlet/file_exists">
     7      <img align="middle" height="125px"
     8           tal:attributes="src python: view.url(context, viewlet.download_name)" />
     9      &nbsp;
     10      <input type="submit"
     11       tal:attributes="id python:('delete_%s' % viewlet.input_name);
     12          name python:('delete_%s' % viewlet.input_name)"
     13       value="Delete" class="btn btn-danger" />
     14      <br /><br />
     15    </tal:file_exists>
    1516                <div class="input-group">
    1617                        <div class="input-group-btn">
  • main/waeup.kofa/trunk/src/waeup/kofa/students/fileviewlets.py

    r15880 r16609  
    3737    StudentBaseDisplayFormPage, StudentBaseManageFormPage,
    3838    StudentClearanceDisplayFormPage, StudentClearanceManageFormPage,
    39     ExportPDFClearanceSlip, StudentFilesUploadPage)
     39    ExportPDFClearanceSlip, StudentFilesUploadPage, StudentSignatureUploadPage)
    4040
    4141grok.context(IKofaObject) # Make IKofaObject the default context
     
    8383
    8484
    85 # File viewlets for student base page
     85# File viewlets for student base and clearance page
    8686
    8787class PassportDisplay(StudentFileDisplay):
     
    115115
    116116
     117class SignatureDisplay(StudentFileDisplay):
     118    """Signature display viewlet.
     119    """
     120    grok.order(2)
     121    grok.context(IStudent)
     122    grok.view(StudentBaseDisplayFormPage)
     123    grok.require('waeup.viewStudent')
     124    grok.template('imagedisplay')
     125    label = _(u'Scanned Signature')
     126    download_name = u'signature.jpg'
     127
     128
     129class SignatureUploadManage(StudentFileUpload):
     130    """Signature upload viewlet for officers.
     131    """
     132    grok.order(2)
     133    grok.context(IStudent)
     134    grok.view(StudentBaseManageFormPage)
     135    grok.require('waeup.manageStudent')
     136    grok.template('imageupload')
     137    label = _(u'Scanned Signature (jpg only)')
     138    download_name = u'signature.jpg'
     139    tab_redirect = '#tab2'
     140
     141    @property
     142    def mus(self):
     143        kofa_utils = getUtility(IKofaUtils)
     144        return kofa_utils.MAX_PASSPORT_SIZE
     145
     146
    117147class PassportUploadEdit(PassportUploadManage):
    118148    """Passport upload viewlet for students.
    119149    """
    120150    grok.view(StudentFilesUploadPage)
     151    grok.require('waeup.uploadStudentFile')
     152
     153
     154class SignatureUploadEdit(SignatureUploadManage):
     155    """Signature upload viewlet for students.
     156    """
     157    grok.view(StudentSignatureUploadPage)
    121158    grok.require('waeup.uploadStudentFile')
    122159
     
    152189    grok.context(IStudent)
    153190
     191class Signature(StudentImage):
     192    """Renders jpeg signature.
     193    """
     194    grok.name('signature.jpg')
     195    download_name = u'signature.jpg'
     196    grok.context(IStudent)
    154197
    155198class ApplicationSlipImage(StudentImage):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r16526 r16609  
    681681        # Only the Application Slip does not exist
    682682        self.assertFalse('Application Slip' in self.browser.contents)
     683        return
     684
     685    def test_upload_files(self):
     686        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     687        self.browser.open(self.manage_student_path)
     688        self.browser.getControl(name="form.firstname").value = 'John'
     689        self.browser.getControl(name="form.lastname").value = 'Tester'
     690        self.browser.getControl(name="form.reg_number").value = '345'
     691        self.browser.getControl(name="password").value = 'secret'
     692        self.browser.getControl(name="control_password").value = 'secret'
     693        self.browser.getControl("Save").click()
     694        self.assertMatches('...Form has been saved...',
     695                           self.browser.contents)
     696        ctrl = self.browser.getControl(name='passportuploadmanage')
     697        file_obj = open(SAMPLE_IMAGE, 'rb')
     698        file_ctrl = ctrl.mech_control
     699        file_ctrl.add_file(file_obj, filename='my_photo.jpg')
     700        self.browser.getControl(
     701            name='upload_passportuploadmanage').click()
     702        self.assertTrue(
     703            'src="http://localhost/app/students/K1000000/passport.jpg"'
     704            in self.browser.contents)
     705        ctrl = self.browser.getControl(name='signatureuploadmanage')
     706        file_obj = open(SAMPLE_IMAGE, 'rb')
     707        file_ctrl = ctrl.mech_control
     708        file_ctrl.add_file(file_obj, filename='my_signature.jpg')
     709        self.browser.getControl(
     710            name='upload_signatureuploadmanage').click()
     711        self.assertTrue(
     712            'src="http://localhost/app/students/K1000000/signature.jpg"'
     713            in self.browser.contents)
    683714        return
    684715
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r16442 r16609  
    12421242    PORTRAIT_CHANGE_STATES = (ADMITTED,)
    12431243
     1244    #: A tuple containing the names of registration states in which changing of
     1245    #: scanned signatures is allowed.
     1246    SIGNATURE_CHANGE_STATES = ()
     1247
    12441248    #: A tuple containing all exporter names referring to students or
    12451249    #: subobjects thereof.
  • main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py

    r16523 r16609  
    623623        return self.view.url(self.view.context, self.target)
    624624
     625class StudentSignatureActionButton(ManageActionButton):
     626    grok.order(4)
     627    grok.context(IStudent)
     628    grok.view(StudentBaseDisplayFormPage)
     629    grok.require('waeup.handleStudent')
     630    icon = 'actionicon_signature.png'
     631    text = _('Change signature')
     632    target = 'change_signature'
     633
     634    @property
     635    def target_url(self):
     636        SIGNATURE_CHANGE_STATES = getUtility(
     637            IStudentsUtils).SIGNATURE_CHANGE_STATES
     638        if self.context.state not in SIGNATURE_CHANGE_STATES:
     639            return ''
     640        return self.view.url(self.view.context, self.target)
     641
    625642
    626643class StudentClearanceStartActionButton(ManageActionButton):
Note: See TracChangeset for help on using the changeset viewer.