Changeset 17811


Ignore:
Timestamp:
6 Jun 2024, 11:11:23 (4 months ago)
Author:
Henrik Bettermann
Message:

Use allowPortraitChange utility method.

Location:
main/kofacustom.nigeria/trunk
Files:
3 edited
1 moved

Legend:

Unmodified
Added
Removed
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/browser.py

    r17141 r17811  
    248248        'flash_notice')
    249249
    250 class NigeriaStudentFilesUploadPage(StudentFilesUploadPage):
    251     """ View to upload passport picture.
    252 
    253     Students are not allowed to change the picture if they
    254     passed the regular Kofa application.
    255     """
    256 
    257     def update(self):
    258         # Passport pictures must not be editable if application slip
    259         # exists.
    260         slip = getUtility(IExtFileStore).getFileByContext(
    261             self.context, 'application_slip')
    262         PORTRAIT_CHANGE_STATES = getUtility(IStudentsUtils).PORTRAIT_CHANGE_STATES
    263         if self.context.state not in PORTRAIT_CHANGE_STATES or slip is not None:
    264             emit_lock_message(self)
    265             return
    266         return
    267 
    268250class ClearStudentFinancially(UtilityView, grok.View):
    269251    """ Clear student financially by financial clearance officer
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/utils.py

    r15651 r17811  
    1717##
    1818import grok
     19from zope.component import getUtility
     20from waeup.kofa.interfaces import IExtFileStore
    1921from waeup.kofa.students.utils import StudentsUtils
    2022from kofacustom.nigeria.interfaces import MessageFactory as _
     
    4143    # Maximum size of upload files in kB
    4244    MAX_KB = 250
     45
     46    def allowPortraitChange(self, student):
     47        """Check if student is allowed to change the portrait file.
     48        """
     49        # Passport pictures must not be editable if application slip
     50        # exists. Students are not allowed to change the picture if they passed
     51        # the regular Kofa application.
     52        slip = getUtility(IExtFileStore).getFileByContext(
     53            student, 'application_slip')
     54        if student.state not in self.PORTRAIT_CHANGE_STATES or slip is not None:
     55            return False
     56        return True
     57
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/viewlets.py

    r15846 r17811  
    4141    return False
    4242
    43 class StudentPassportActionButton(StudentPassportActionButton):
    44 
    45     @property
    46     def target_url(self):
    47         # Passport pictures must not be editable if application slip
    48         # exists.
    49         slip = getUtility(IExtFileStore).getFileByContext(
    50             self.context, 'application_slip')
    51         PORTRAIT_CHANGE_STATES = getUtility(IStudentsUtils).PORTRAIT_CHANGE_STATES
    52         if self.context.state not in PORTRAIT_CHANGE_STATES or slip is not None:
    53             return ''
    54         return self.view.url(self.view.context, self.target)
    55 
    5643class PaymentReceiptActionButton(PaymentReceiptActionButton):
    5744    grok.order(4)
Note: See TracChangeset for help on using the changeset viewer.