Skip to content

Commit

Permalink
Fix delete url for modeladmin instances with Wagtail > 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
zerolab committed May 9, 2022
1 parent c86c7c2 commit 770a0c0
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions wagtail_localize/views/edit_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,21 @@ def get_edit_url(instance):
args=[quote(instance.pk)],
)

def get_delete_url(instance):
if isinstance(instance, Page):
return reverse("wagtailadmin_pages:delete", args=[instance.id])
elif instance._meta.model in get_snippet_models():
return get_snippet_delete_url(instance)

elif "wagtail_localize.modeladmin" in settings.INSTALLED_APPS:
return reverse(
"{app_label}_{model_name}_modeladmin_delete".format(
app_label=instance._meta.app_label,
model_name=instance._meta.model_name,
),
args=[quote(instance.pk)],
)

def get_submit_translation_url(instance):
if isinstance(instance, Page):
return reverse(
Expand Down Expand Up @@ -974,11 +989,7 @@ def get_translation_progress(segment, locale):
)
if isinstance(instance, Page)
else None,
"deleteUrl": reverse(
"wagtailadmin_pages:delete", args=[instance.id]
)
if isinstance(instance, Page)
else get_snippet_delete_url(instance),
"deleteUrl": get_delete_url(instance),
"stopTranslationUrl": reverse(
"wagtail_localize:stop_translation", args=[translation.id]
),
Expand Down

0 comments on commit 770a0c0

Please sign in to comment.