Ignore:
Timestamp:
10 Jan 2021, 22:30:18 (4 years ago)
Author:
Henrik Bettermann
Message:

Start customization of StudentFilesUploadPage? and StudentPassportActionButton?.

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

Legend:

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

    r16171 r16361  
    5656    NigeriaAccommodationDisplayFormPage,
    5757    NigeriaStudentBaseDisplayFormPage,
     58    NigeriaStudentFilesUploadPage,
    5859    )
    5960
     
    738739        'email', 'phone')
    739740    form_fields['email'].field.required = True
     741
     742class CustomStudentFilesUploadPage(NigeriaStudentFilesUploadPage):
     743    """ View to upload passport picture.
     744
     745    Students are not allowed to change the picture if they
     746    passed the regular Kofa application.
     747    """
     748
     749    def update(self):
     750        # Passport pictures must not be editable if application slip
     751        # exists.
     752        slip = getUtility(IExtFileStore).getFileByContext(
     753            self.context, 'application_slip')
     754        PORTRAIT_CHANGE_STATES = getUtility(IStudentsUtils).PORTRAIT_CHANGE_STATES
     755        if self.context.state not in PORTRAIT_CHANGE_STATES or slip is not None:
     756            emit_lock_message(self)
     757            return
     758        super(StudentFilesUploadPage, self).update()
     759        return
  • main/waeup.uniben/trunk/src/waeup/uniben/students/viewlets.py

    r16359 r16361  
    1818
    1919import grok
    20 from waeup.kofa.interfaces import REQUESTED, REGISTERED
     20from zope.component import getUtility
     21from waeup.kofa.interfaces import REQUESTED, REGISTERED, IExtFileStore
    2122from waeup.kofa.browser.viewlets import ManageActionButton
    22 from waeup.uniben.students.interfaces import (
    23     ICustomStudentStudyCourse, ICustomStudentStudyLevel,
    24     ICustomStudent, )
     23from waeup.kofa.students.interfaces import IStudentsUtils
    2524from waeup.kofa.students.fileviewlets import (
    2625    StudentFileDisplay, StudentFileUpload, StudentImage,)
     
    2928    StudyLevelDisplayFormPage, StudentClearanceDisplayFormPage,
    3029    StudentBaseDisplayFormPage)
    31 from waeup.kofa.students.viewlets import RequestTranscriptActionButton
     30from waeup.kofa.students.viewlets import (
     31    RequestTranscriptActionButton, StudentPassportActionButton)
     32
     33from waeup.uniben.students.interfaces import (
     34    ICustomStudentStudyCourse, ICustomStudentStudyLevel,
     35    ICustomStudent, )
    3236
    3337from kofacustom.nigeria.interfaces import MessageFactory as _
     
    3842    def target_url(self):
    3943        return ''
     44
     45class CustomStudentPassportActionButton(StudentPassportActionButton):
     46
     47    @property
     48    def target_url(self):
     49        # Passport pictures must not be editable if application slip
     50        # exists.
     51        slip = getUtility(IExtFileStore).getFileByContext(
     52            self.context, 'application_slip')
     53        PORTRAIT_CHANGE_STATES = getUtility(IStudentsUtils).PORTRAIT_CHANGE_STATES
     54        if self.context.state not in PORTRAIT_CHANGE_STATES or slip is not None:
     55            return ''
     56        return self.view.url(self.view.context, self.target)
    4057
    4158class SwitchLibraryAccessActionButton(ManageActionButton):
Note: See TracChangeset for help on using the changeset viewer.