Ignore:
Timestamp:
30 Jan 2020, 22:47:56 (5 years ago)
Author:
Henrik Bettermann
Message:

Add waeup.local.ReportsOfficer role.

File:
1 edited

Legend:

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

    r14628 r15968  
    2727from waeup.kofa.interfaces import MessageFactory as _
    2828from waeup.kofa.browser.layout import KofaPage, jsaction
    29 from waeup.kofa.utils.helpers import get_current_principal
     29from waeup.kofa.utils.helpers import get_current_principal, get_user_account
    3030from waeup.kofa.reports import (
    3131    IReportsContainer, IReportGenerator, get_generators)
     
    142142    label = _('Create report')
    143143
     144    locally_allowed_reports = (
     145        'level_report', 'raw_score_report', 'session_results_presentation')
     146
    144147    def update(self, START_GENERATOR=None, generator=None):
    145148        utils = queryUtility(IKofaUtils)
     
    162165        being a human readable description of the respective generator
    163166        and ``<NAME>`` being the registration name with the ZCA.
     167
     168        If `waeup.local.ReportsOfficer` role has been assigned at
     169        department level, list only report generator which allow
     170        to filter department data.
    164171        """
    165         result = [(gen.title, name) for name, gen in get_generators()]
     172        try:
     173            local_roles = get_user_account(self.request).getLocalRoles()
     174        except AttributeError:  # Managers have no user account
     175            local_roles = {}
     176        lror = local_roles.get('waeup.local.ReportsOfficer', None)
     177        if lror:
     178            result = [(gen.title, name) for name, gen in get_generators()
     179                                        if name in self.locally_allowed_reports]
     180        else:
     181            result = [(gen.title, name) for name, gen in get_generators()]
    166182        sorted_result = sorted(result, key=lambda value:value[1])
    167183        return sorted_result
Note: See TracChangeset for help on using the changeset viewer.