mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Fix unhandled not found error when manually managing sync jobs (#5412)
* Fix unhandled not found error when manually managing sync jobs * Improve info text (suggestions from code review) Co-authored-by: luelista <weller@rami.io> --------- Co-authored-by: luelista <weller@rami.io>
This commit is contained in:
committed by
GitHub
parent
24ac588119
commit
09e9273a57
@@ -82,27 +82,35 @@ class ControlSyncJob(OrderView):
|
||||
messages.success(self.request, _('The sync job has been enqueued and will run in the next minutes.'))
|
||||
elif self.request.POST.get("cancel_job"):
|
||||
with transaction.atomic():
|
||||
job = self.order.queued_sync_jobs.select_for_update(of=OF_SELF).get(
|
||||
pk=self.request.POST.get("cancel_job")
|
||||
)
|
||||
if job.in_flight:
|
||||
messages.warning(self.request, _('The sync job is already in progress.'))
|
||||
try:
|
||||
job = self.order.queued_sync_jobs.select_for_update(of=OF_SELF).get(
|
||||
pk=self.request.POST.get("cancel_job")
|
||||
)
|
||||
except OrderSyncQueue.DoesNotExist:
|
||||
messages.info(self.request, _('The sync job could not be found. It may have been processed in the meantime.'))
|
||||
else:
|
||||
job.delete()
|
||||
messages.success(self.request, _('The sync job has been canceled.'))
|
||||
if job.in_flight:
|
||||
messages.warning(self.request, _('The sync job is already in progress.'))
|
||||
else:
|
||||
job.delete()
|
||||
messages.success(self.request, _('The sync job has been canceled.'))
|
||||
elif self.request.POST.get("run_job_now"):
|
||||
with transaction.atomic():
|
||||
job = self.order.queued_sync_jobs.select_for_update(of=OF_SELF).get(
|
||||
pk=self.request.POST.get("run_job_now")
|
||||
)
|
||||
if job.in_flight:
|
||||
messages.success(self.request, _('The sync job is already in progress.'))
|
||||
try:
|
||||
job = self.order.queued_sync_jobs.select_for_update(of=OF_SELF).get(
|
||||
pk=self.request.POST.get("run_job_now")
|
||||
)
|
||||
except OrderSyncQueue.DoesNotExist:
|
||||
messages.info(self.request, _('The sync job could not be found. It may have been processed in the meantime.'))
|
||||
else:
|
||||
job.not_before = now()
|
||||
job.need_manual_retry = None
|
||||
job.save()
|
||||
sync_single.apply_async(args=(job.pk,))
|
||||
messages.success(self.request, _('The sync job has been set to run as soon as possible.'))
|
||||
if job.in_flight:
|
||||
messages.success(self.request, _('The sync job is already in progress.'))
|
||||
else:
|
||||
job.not_before = now()
|
||||
job.need_manual_retry = None
|
||||
job.save()
|
||||
sync_single.apply_async(args=(job.pk,))
|
||||
messages.success(self.request, _('The sync job has been set to run as soon as possible.'))
|
||||
|
||||
return redirect(self.get_order_url())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user