Changeset 10146 for main/waeup.futminna


Ignore:
Timestamp:
2 May 2013, 20:01:17 (12 years ago)
Author:
Henrik Bettermann
Message:

If an applicant is removed also pdf files of this applicant have to be removed.

Location:
main/waeup.futminna/trunk/src/waeup/futminna/applicants
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.futminna/trunk/src/waeup/futminna/applicants/applicant.py

    r9065 r10146  
    1919import grok
    2020from zope.interface import implementedBy
     21from zope.component import getUtility
     22from waeup.kofa.interfaces import IExtFileStore
    2123from waeup.kofa.applicants.applicant import ApplicantFactory
    2224from waeup.kofa.utils.helpers import attrs_to_fields
     
    2426from waeup.futminna.applicants.interfaces import(
    2527    ICustomApplicant, ICustomUGApplicantEdit, ICustomPGApplicantEdit, IPUTMEApplicantEdit)
     28
     29@grok.subscribe(ICustomApplicant, grok.IObjectRemovedEvent)
     30def custom_handle_applicant_removed(applicant, event):
     31    """If an applicant is removed also pdf files of this applicant are removed.
     32    """
     33    file_store = getUtility(IExtFileStore)
     34    file_store.deleteFileByContext(applicant, attr='extraform.pdf')
     35    file_store.deleteFileByContext(applicant, attr='refereeform.pdf')
     36    return
    2637
    2738class CustomApplicant(NigeriaApplicant):
  • main/waeup.futminna/trunk/src/waeup/futminna/applicants/tests/test_browser.py

    r10105 r10146  
    151151            % (self.applicant.applicant_id)
    152152            in logcontent)
     153        # When an applicant is removed, also the pdf files are gone.
     154        del self.app['applicants']['app2011'][self.applicant.application_number]
     155        fd = storage.getFile(file_id)
     156        self.assertTrue(fd is None)
    153157
    154158    def test_upload_refereeform_by_student(self):
     
    238242            % (self.applicant.applicant_id)
    239243            in logcontent)
     244        # When an applicant is removed, also the pdf files are gone.
     245        del self.app['applicants']['app2011'][self.applicant.application_number]
     246        fd = storage.getFile(file_id)
     247        self.assertTrue(fd is None)
Note: See TracChangeset for help on using the changeset viewer.