Organizer/MultiEvent-Exports (#1684)

Co-authored-by: Raphael Michel <michel@rami.io>
This commit is contained in:
Martin Gross
2020-06-16 11:06:40 +02:00
committed by GitHub
parent e895c13b28
commit 0b20d3f6f8
14 changed files with 384 additions and 78 deletions

View File

@@ -19,7 +19,7 @@ from django_scopes import scope, scopes_disabled
from pretix.base.metrics import (
pretix_task_duration_seconds, pretix_task_runs_total,
)
from pretix.base.models import Event
from pretix.base.models import Event, Organizer, User
from pretix.celery_app import app
@@ -88,10 +88,30 @@ class EventTask(app.Task):
return ret
class OrganizerUserTask(app.Task):
def __call__(self, *args, **kwargs):
organizer_id = kwargs['organizer']
with scopes_disabled():
organizer = Organizer.objects.get(pk=organizer_id)
kwargs['organizer'] = organizer
user_id = kwargs['user']
user = User.objects.get(pk=user_id)
kwargs['user'] = user
with scope(organizer=organizer):
ret = super().__call__(*args, **kwargs)
return ret
class ProfiledEventTask(ProfiledTask, EventTask):
pass
class ProfiledOrganizerUserTask(ProfiledTask, OrganizerUserTask):
pass
class TransactionAwareTask(ProfiledTask):
"""
Task class which is aware of django db transactions and only executes tasks