Skip to content

fix: 7605 delete translations #8123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add item "Delete this translation" to context menu in page tree
  • Loading branch information
jrief committed Jan 28, 2025
commit 05b5ba8dd09b2b7816ea28a0542972e72d81e7e4
5 changes: 5 additions & 0 deletions cms/admin/pageadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,14 @@ def actions_menu(self, request, object_id, extra_context=None):
raise self._get_404_exception(object_id)

site = get_site(request)
preview_language = request.GET.get('language')
page_content = page.get_content_obj(request.GET.get('language'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
page_content = page.get_content_obj(request.GET.get('language'))
page_content = page.get_content_obj(preview_language)

if not page_content or page_content.language != preview_language:
page_content = None
paste_enabled = request.GET.get('has_copy') or request.GET.get('has_cut')
context = {
'page': page,
'page_content': page_content,
'opts': self.opts,
'site': site,
'page_is_restricted': page.has_view_restrictions(site),
Expand Down
14 changes: 12 additions & 2 deletions cms/templates/admin/cms/page/tree/actions_dropdown.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,22 @@
</li>
<li>
{% if has_delete_permission %}
<a href="{% url opts|admin_urlname:'delete' page.id %}" title="{% filter escapejs %}{% trans "Delete" %}{% endfilter %}">
<a href="{% url opts|admin_urlname:'delete' page.id %}" title="{% filter escapejs %}{% trans "Delete all translations" %}{% endfilter %}">
{% else %}
<a href="#" class="cms-pagetree-dropdown-item-disabled">
{% endif %}
<span class="cms-icon cms-icon-bin"></span>
<span>{% trans "Delete" %}...</span>
<span>{% trans "Delete all translations" %}...</span>
</a>
</li>
<li>
{% if has_delete_permission and page_content %}
<a href="{% url 'admin:cms_pagecontent_delete' object_id=page_content.id %}" title="{% filter escapejs %}{% trans "Delete this translation" %}{% endfilter %}">
{% else %}
<a href="#" class="cms-pagetree-dropdown-item-disabled">
{% endif %}
<span class="cms-icon cms-icon-bin"></span>
<span>{% trans "Delete this translation" %}...</span>
</a>
</li>
{% if has_change_permission and page.is_potential_home %}
Expand Down
2 changes: 1 addition & 1 deletion cms/templates/admin/cms/page/tree/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
{% endif %}
</div>
</div>
<div class="js-cms-pagetree-actions-dropdown cms-tree-item cms-tree-item-button cms-pagetree-dropdown js-cms-pagetree-dropdown" data-lazy-url="{% url 'admin:cms_page_actions_menu' page.pk %}">
<div class="js-cms-pagetree-actions-dropdown cms-tree-item cms-tree-item-button cms-pagetree-dropdown js-cms-pagetree-dropdown" data-lazy-url="{% url 'admin:cms_page_actions_menu' page.pk %}" data-lazy-url-data="language={{ preview_language }}">
<a data-node-id="{{ page.pk|unlocalize }}" data-id="{{ page.pk|unlocalize }}" href="#" class="js-cms-pagetree-dropdown-trigger js-cms-pagetree-options cms-pagetree-dropdown-trigger cms-btn cms-btn-default cms-btn-no-border cms-icon cms-icon-menu">
<span class="sr-only">{% autoescape on %}{% trans "Options" %}{% endautoescape %}</span>
</a>
Expand Down