Add BaseExporter.available_for_user()

This commit is contained in:
Raphael Michel
2023-06-16 17:33:14 +02:00
parent 7a48cac862
commit b51ca58820
5 changed files with 23 additions and 4 deletions

View File

@@ -157,6 +157,13 @@ class BaseExporter:
"""
raise NotImplementedError() # NOQA
def available_for_user(self, user) -> bool:
"""
Allows to do additional checks whether an exporter is available based on the user who calls it. Note that
``user`` may be ``None`` e.g. during API usage.
"""
return True
class OrganizerLevelExportMixin:
@property

View File

@@ -290,6 +290,8 @@ def scheduled_organizer_export(self, organizer: Organizer, schedule: int) -> Non
if isinstance(exporter, OrganizerLevelExportMixin):
if not schedule.owner.has_organizer_permission(organizer, exporter.organizer_required_permission):
has_permission = False
if exporter and not exporter.available_for_user(schedule.owner):
has_permission = False
_run_scheduled_export(
schedule,