Skip to content

Commit

Permalink
feat: Re-introduce deleting languages of a page
Browse files Browse the repository at this point in the history
  • Loading branch information
fsbraun committed Jan 15, 2025
1 parent 59e06b9 commit 4aad1d8
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions djangocms_versioning/cms_toolbars.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from django.utils.http import urlencode
from django.utils.translation import gettext_lazy as _

from djangocms_versioning.conf import LOCK_VERSIONS
from djangocms_versioning.conf import ALLOW_DELETING_VERSIONS, LOCK_VERSIONS
from djangocms_versioning.constants import DRAFT, PUBLISHED
from djangocms_versioning.helpers import (
get_latest_admin_viewable_content,
Expand Down Expand Up @@ -385,6 +385,18 @@ def change_language_menu(self):
)
add_plugins_menu.add_modal_item(name, url=url)

if remove and ALLOW_DELETING_VERSIONS:
remove_plugins_menu = language_menu.get_or_create_menu(
f'{LANGUAGE_MENU_IDENTIFIER}-del', _('Delete Translation')

Check failure on line 390 in djangocms_versioning/cms_toolbars.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (Q000)

djangocms_versioning/cms_toolbars.py:390:21: Q000 Single quotes found but double quotes preferred

Check failure on line 390 in djangocms_versioning/cms_toolbars.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (Q000)

djangocms_versioning/cms_toolbars.py:390:58: Q000 Single quotes found but double quotes preferred

Check failure on line 390 in djangocms_versioning/cms_toolbars.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (Q000)

djangocms_versioning/cms_toolbars.py:390:21: Q000 Single quotes found but double quotes preferred

Check failure on line 390 in djangocms_versioning/cms_toolbars.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (Q000)

djangocms_versioning/cms_toolbars.py:390:58: Q000 Single quotes found but double quotes preferred
)
disabled = len(remove) == 1
for code, name in remove:
pagecontent = self.page.get_admin_content(language=code)
if pagecontent:
translation_delete_url = admin_reverse('cms_pagecontent_delete', args=(pagecontent.pk,))

Check failure on line 396 in djangocms_versioning/cms_toolbars.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (Q000)

djangocms_versioning/cms_toolbars.py:396:64: Q000 Single quotes found but double quotes preferred

Check failure on line 396 in djangocms_versioning/cms_toolbars.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (Q000)

djangocms_versioning/cms_toolbars.py:396:64: Q000 Single quotes found but double quotes preferred
url = add_url_parameters(translation_delete_url, language=code)
remove_plugins_menu.add_modal_item(name, url=url, disabled=disabled)

if copy:
copy_plugins_menu = language_menu.get_or_create_menu(
f"{LANGUAGE_MENU_IDENTIFIER}-copy", _("Copy all plugins")
Expand All @@ -394,7 +406,7 @@ def change_language_menu(self):
item_added = False
for code, name in copy:
# Get the Draft or Published PageContent.
page_content = self.get_page_content(language=code)
page_content = self.page.get_admin_content(language=code)
if page_content: # Only offer to copy if content for source language exists
page_copy_url = admin_reverse("cms_pagecontent_copy_language", args=(page_content.pk,))
copy_plugins_menu.add_ajax_item(
Expand Down

0 comments on commit 4aad1d8

Please sign in to comment.