Skip to content

Commit

Permalink
Check that the retried job is the latest
Browse files Browse the repository at this point in the history
  • Loading branch information
zerolab committed Sep 19, 2024
1 parent 3ca752b commit a7f9dd0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/wagtail_localize_smartling/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@ def dispatch(self, request, *args, **kwargs):
if self.object.status not in UNTRANSLATED_STATUSES:
return permission_denied(request)

# Check that the given Job is the latest. We can use any of its translations
translation = self.object.translations.first()
if translation is None:
# should cover the case where the translation was converted back to an alias
return permission_denied(request)

# Jobs are ordered by `first_synced_at`, with null values coming at the top
# then pk descending.
if translation.smartling_jobs.values_list("pk", flat=True)[0] != self.object.pk:
return permission_denied(request)

self.jobs_report_url = reverse("wagtail_localize_smartling_jobs:index")
return super().dispatch(request, *args, **kwargs)

Expand Down

0 comments on commit a7f9dd0

Please sign in to comment.