Ignore:
Timestamp:
27 Jun 2024, 09:18:42 (6 months ago)
Author:
Henrik Bettermann
Message:

Make _set_exporter_values customizable.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
2 edited

Legend:

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

    r17810 r17823  
    43444344
    43454345    def _set_exporter_values(self):
    4346         # We provide all student exporters, nothing else, yet.
    4347         # Bursary, Department or Accommodation Officers don't
    4348         # have the general exportData
    4349         # permission and are only allowed to export bursary, payments
    4350         # overview or accommodation data respectively.
    4351         # This is the only place where waeup.exportAccommodationData,
    4352         # waeup.exportBursaryData and waeup.exportPaymentsOverview
    4353         # are used.
     4346        kofa_utils = getUtility(IKofaUtils)
     4347        exporters = kofa_utils.collect_exporters(self.context)
     4348        if exporters:
     4349            self.exporters = exporters
     4350            return
    43544351        exporters = []
    4355         if not checkPermission('waeup.exportData', self.context):
    4356             if checkPermission('waeup.exportBursaryData', self.context):
    4357                 exporters += [('Bursary Data', 'bursary')]
    4358             if checkPermission('waeup.exportPaymentsOverview', self.context):
    4359                 exporters += [('School Fee Payments Overview',
    4360                                'sfpaymentsoverview'),
    4361                               ('Session Payments Overview',
    4362                                'sessionpaymentsoverview')]
    4363             if checkPermission('waeup.exportAccommodationData', self.context):
    4364                 exporters += [('Bed Tickets', 'bedtickets'),
    4365                               ('Accommodation Payments',
    4366                                'accommodationpayments')]
    4367             self.exporters = exporters
    4368             return
    43694352        STUDENT_EXPORTER_NAMES = getUtility(
    43704353            IStudentsUtils).STUDENT_EXPORTER_NAMES
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/utils.py

    r17798 r17823  
    2626from random import SystemRandom as r
    2727from zope.i18n import translate
     28from zope.security import checkPermission
    2829from waeup.kofa.interfaces import IKofaUtils
    2930from waeup.kofa.interfaces import MessageFactory as _
     
    567568        value = int(pow(10, prec)*value) / (1.0*pow(10, prec))
    568569        return '{:{width}.{prec}f}'.format(value, width=0, prec=prec)
     570
     571    def collect_exporters(self, context):
     572        # Used for `ExportJobContainerJobConfig`.
     573        # We provide all student exporters, nothing else, yet.
     574        # Bursary, Department or Accommodation Officers don't
     575        # have the general exportData
     576        # permission and are only allowed to export bursary, payments
     577        # overview or accommodation data respectively.
     578        # This is the only place where waeup.exportAccommodationData,
     579        # waeup.exportBursaryData and waeup.exportPaymentsOverview
     580        # are used.
     581        exporters = []
     582        if not checkPermission('waeup.exportData', context):
     583            if checkPermission('waeup.exportBursaryData', context):
     584                exporters += [('Bursary Data', 'bursary')]
     585            if checkPermission('waeup.exportPaymentsOverview', context):
     586                exporters += [('School Fee Payments Overview',
     587                               'sfpaymentsoverview'),
     588                              ('Session Payments Overview',
     589                               'sessionpaymentsoverview')]
     590            if checkPermission('waeup.exportAccommodationData', context):
     591                exporters += [('Bed Tickets', 'bedtickets'),
     592                              ('Accommodation Payments',
     593                               'accommodationpayments')]
     594            return exporters
Note: See TracChangeset for help on using the changeset viewer.