Skip to content

Commit

Permalink
Merge branch 'master' into fix/remove-patching
Browse files Browse the repository at this point in the history
  • Loading branch information
fsbraun authored Dec 21, 2022
2 parents d6d33dc + 5fe601b commit 7b60aca
Show file tree
Hide file tree
Showing 19 changed files with 93 additions and 106 deletions.
43 changes: 24 additions & 19 deletions djangocms_versioning/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from cms.models import PageContent
from cms.utils import get_language_from_request
from cms.utils.conf import get_cms_setting
from cms.utils.urlutils import add_url_parameters
from cms.utils.urlutils import add_url_parameters, static_with_version

from . import versionables
from .conf import USERNAME_FIELD
Expand Down Expand Up @@ -130,6 +130,7 @@ class Media:
js = ("admin/js/jquery.init.js", "djangocms_versioning/js/actions.js")
css = {
"all": (
static_with_version("cms/css/cms.pagetree.css"),
"djangocms_versioning/css/actions.css",
)
}
Expand Down Expand Up @@ -212,7 +213,7 @@ def list_actions(obj):

def _get_preview_link(self, obj, request, disabled=False):
"""
Return a user friendly button for previewing the content model
Return a user-friendly button for previewing the content model
:param obj: Instance of versioned content model
:param request: The request to admin menu
:param disabled: Should the link be marked disabled?
Expand All @@ -229,7 +230,7 @@ def _get_preview_link(self, obj, request, disabled=False):

def _get_edit_link(self, obj, request, disabled=False):
"""
Return a user friendly button for editing the content model
Return a user-friendly button for editing the content model
- mark disabled if user doesn't have permission
- hide completely if instance cannot be edited
:param obj: Instance of Versioned model
Expand All @@ -254,7 +255,7 @@ def _get_edit_link(self, obj, request, disabled=False):
)
return render_to_string(
"djangocms_versioning/admin/icons/edit_icon.html",
{"url": url, "disabled": disabled, "get": False},
{"url": url, "disabled": disabled, "get": False, "keepsideframe": False},
)

def _get_manage_versions_link(self, obj, request, disabled=False):
Expand Down Expand Up @@ -400,7 +401,10 @@ class VersionAdmin(admin.ModelAdmin):

class Media:
js = ("admin/js/jquery.init.js", "djangocms_versioning/js/actions.js", "djangocms_versioning/js/compare.js",)
css = {"all": ("djangocms_versioning/css/actions.css",)}
css = {"all": (
static_with_version("cms/css/cms.pagetree.css"),
"djangocms_versioning/css/actions.css",
)}

# register custom actions
actions = ["compare_versions"]
Expand Down Expand Up @@ -491,17 +495,17 @@ def _get_archive_link(self, obj, request, disabled=False):
),
args=(obj.pk,),
)
disabled = not obj.check_archive.as_bool(request.user)
disabled = not obj.can_be_archived()

return render_to_string(
"djangocms_versioning/admin/archive_icon.html",
{"archive_url": archive_url, "disabled": disabled},
"djangocms_versioning/admin/icons/archive_icon.html",
{"url": archive_url, "disabled": disabled},
)

def _get_publish_link(self, obj, request):
"""Helper function to get the html link to the publish action
"""
if not obj.can_be_published():
if not obj.check_publish.as_bool(request.user):
# Don't display the link if it can't be published
return ""
publish_url = reverse(
Expand All @@ -510,16 +514,17 @@ def _get_publish_link(self, obj, request):
),
args=(obj.pk,),
)
disabled = not obj.check_publish.as_bool(request.user)
disabled = not obj.can_be_published()

return render_to_string(
"djangocms_versioning/admin/publish_icon.html", {"publish_url": publish_url, "disabled": disabled}
"djangocms_versioning/admin/icons/publish_icon.html",
{"url": publish_url, "disabled": disabled, "get": False, "keepsideframe": False}
)

def _get_unpublish_link(self, obj, request, disabled=False):
"""Helper function to get the html link to the unpublish action
"""
if not obj.can_be_unpublished():
if not obj.check_unpublish.as_bool(request.user):
# Don't display the link if it can't be unpublished
return ""
unpublish_url = reverse(
Expand All @@ -528,11 +533,11 @@ def _get_unpublish_link(self, obj, request, disabled=False):
),
args=(obj.pk,),
)
disabled = not obj.check_unpublish.as_bool(request.user)
disabled = not obj.can_be_unpublished()

return render_to_string(
"djangocms_versioning/admin/unpublish_icon.html",
{"unpublish_url": unpublish_url, "disabled": disabled},
"djangocms_versioning/admin/icons/unpublish_icon.html",
{"url": unpublish_url, "disabled": disabled},
)

def _get_edit_link(self, obj, request, disabled=False):
Expand Down Expand Up @@ -589,8 +594,8 @@ def _get_revert_link(self, obj, request, disabled=False):
)

return render_to_string(
"djangocms_versioning/admin/revert_icon.html",
{"revert_url": revert_url, "disabled": disabled},
"djangocms_versioning/admin/icons/revert_icon.html",
{"url": revert_url, "disabled": disabled},
)

def _get_discard_link(self, obj, request, disabled=False):
Expand All @@ -608,8 +613,8 @@ def _get_discard_link(self, obj, request, disabled=False):
)

return render_to_string(
"djangocms_versioning/admin/discard_icon.html",
{"discard_url": discard_url, "disabled": disabled},
"djangocms_versioning/admin/icons/discard_icon.html",
{"url": discard_url, "disabled": disabled},
)

def get_state_actions(self):
Expand Down
18 changes: 12 additions & 6 deletions djangocms_versioning/static/djangocms_versioning/css/actions.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-------------------------------------
Classes for Action btn & Burger menu
Classes for Action btn & Burger menu
---------------------------------------*/

a.btn.cms-versioning-action-btn {
Expand All @@ -23,21 +23,27 @@ a.btn.cms-versioning-action-btn {
box-sizing: border-box;
cursor: pointer;
}

a.btn.cms-versioning-action-btn span
{
font-family: django-cms-iconfont;
font-size: 120%;
}

a.btn.cms-versioning-action-btn img {
width: 20px;
height: 20px;
}

a.btn.cms-versioning-action-btn.inactive {
opacity: 0.3;
filter: alpha(opacity=30);
a.btn.cms-versioning-action-btn.inactive:link,
a.btn.cms-versioning-action-btn.inactive:visited {
color: var(--dca-gray-lighter, var(--border-color, #ccc)) !important;
}


/* disable clicking for inactive buttons */
.btn.cms-versioning-action-btn.inactive {
pointer-events: none;
background-color: #e1e1e1 !important;
}

.btn.cms-versioning-action-btn.inactive img {
Expand All @@ -53,7 +59,7 @@ a.btn.cms-versioning-action-btn img {


/*-------------------------------------
This governs the drop-down behaviour
This governs the drop-down behaviour
extending the pagetree classes provided by CMS
---------------------------------------*/

Expand Down
10 changes: 5 additions & 5 deletions djangocms_versioning/static/djangocms_versioning/js/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
});
};

let toggleBurgerMenu = function toggleBurgerMenu(burgerMenuAnchor, optionsContainer) {
let toggleBurgerMenu = function toggleBurgerMenu(burgerMenuAnchor, optionsContainer) {
let bm = $(burgerMenuAnchor);
let op = $(optionsContainer);
let closed = bm.hasClass('closed');
Expand All @@ -176,16 +176,16 @@
op.css('top', pos.top);
};

let closeBurgerMenu = function closeBurgerMenu() {
let closeBurgerMenu = function closeBurgerMenu() {
$('.cms-actions-dropdown-menu').removeClass('open');
$('.cms-actions-dropdown-menu').addClass('closed');
$('.cms-versioning-action-btn').removeClass('open');
$('.cms-versioning-action-btn').addClass('closed');
};
};

$('#result_list').find('tr').each(function (index, item) {
$('#result_list').find('tr').each(function (index, item) {
createBurgerMenu(item);
});
});

});

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% extends "./base.html" %}
{% load i18n %}
{% block title %}{% translate 'Archive' %}{% endblock %}
{% block name %}archive{% endblock %}
{% block icon %}archive{% endblock %}
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
{% spaceless %}
<a
title="{% block title %}{% endblock %}"
class="btn
{% if disabled %}
inactive
{% endif %}
cms-versioning-action-btn
cms-versioning-action-{% block name %}{% endblock %}
{% if get|default_if_none:True %} cms-form-get-method {% endif %}
{% if action|default_if_none:True %} js-versioning-action{% endif %}
{% if keepsideframe|default_if_none:True %}js-versioning-keep-sideframe {% else %}js-versioning-close-sideframe {% endif %}"
{% if not disabled %}
href="{{ url }}"
{% endif %}
>
<img src="{% block icon %}{% endblock %}">
<a class="btn{% if disabled %} inactive{% endif %}{% if get|default_if_none:True %} cms-form-get-method{% endif %} cms-versioning-action-btn cms-versioning-action-{% block name %}{% endblock %}{% if action|default_if_none:True %} js-versioning-action{% endif %}{% if keepsideframe|default_if_none:True %} js-versioning-keep-sideframe{% else %} js-versioning-close-sideframe{% endif %}"{% if not disabled %} href="{{ url }}"{% endif %} title="{% block title %}{% endblock %}">
<span class="cms-icon cms-icon-{% block icon %}{% endblock %}"></span>
</a>
{% endspaceless %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% extends "./base.html" %}
{% load i18n %}
{% block title %}{% translate 'Discard' %}{% endblock %}
{% block name %}discard{% endblock %}
{% block icon %}bin{% endblock %}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "./base.html" %}
{% load static i18n %}
{% block title %}{% trans 'Edit' %}{% endblock %}
{% load i18n %}
{% block title %}{% translate 'Edit' %}{% endblock %}
{% block name %}edit{% endblock %}
{% block icon %}{% static 'djangocms_versioning/svg/edit.svg' %}{% endblock %}
{% block icon %}pencil{% endblock %}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "./base.html" %}
{% load static i18n %}
{% block title %}{% trans 'Manage versions' %}{% endblock %}
{% load i18n %}
{% block title %}{% translate 'Manage versions' %}{% endblock %}
{% block name %}manage-versions{% endblock %}
{% block icon %}{% static 'djangocms_versioning/svg/manage_versions.svg' %}{% endblock %}
{% block icon %}copy{% endblock %}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "./base.html" %}
{% load static i18n %}
{% block title %}{% trans 'Preview' %}{% endblock %}
{% load i18n %}
{% block title %}{% translate 'Preview' %}{% endblock %}
{% block name %}preview{% endblock %}
{% block icon %}{% static 'djangocms_versioning/svg/preview.svg' %}{% endblock %}
{% block icon %}eye{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% extends "./base.html" %}
{% load i18n %}
{% block title %}{% translate 'Publish' %}{% endblock %}
{% block name %}edit{% endblock %}
{% block icon %}publish{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% extends "./base.html" %}
{% load i18n %}
{% block title %}{% translate 'Revert' %}{% endblock %}
{% block name %}revert{% endblock %}
{% block icon %}undo{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% extends "./base.html" %}
{% load i18n %}
{% block title %}{% translate 'Unpublish' %}{% endblock %}
{% block name %}unpublish{% endblock %}
{% block icon %}unpublish{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% extends "./base.html" %}
{% load i18n %}
{% block title %}{% translate 'View on site' %}{% endblock %}
{% block name %}preview{% endblock %}
{% block icon %}eye{% endblock %}

This file was deleted.

This file was deleted.

This file was deleted.

14 changes: 11 additions & 3 deletions tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,10 @@ def test_revert_action_link_enable_state(self):
self.versionable.version_model_proxy, "revert", version.pk
)
expected_enabled_state = (
'<a class="btn cms-form-get-method cms-versioning-action-btn js-versioning-action '
'<a class="btn cms-form-get-method '
'cms-versioning-action-btn '
'cms-versioning-action-revert '
'js-versioning-action '
'js-versioning-keep-sideframe" '
'href="%s" '
'title="Revert">'
Expand Down Expand Up @@ -545,7 +548,10 @@ def test_discard_action_link_enabled_state(self):
actual_enabled_control = self.version_admin._get_discard_link(version, request)

expected_enabled_state = (
'<a class="btn cms-form-get-method cms-versioning-action-btn js-versioning-action '
'<a class="btn cms-form-get-method '
'cms-versioning-action-btn '
'cms-versioning-action-discard '
'js-versioning-action '
'js-versioning-keep-sideframe" '
'href="%s" '
'title="Discard">'
Expand Down Expand Up @@ -608,7 +614,9 @@ def test_revert_action_link_for_archive_state(self):
self.versionable.version_model_proxy, "revert", archive_version.pk
)
expected_disabled_control = (
'<a class="btn cms-form-get-method cms-versioning-action-btn js-versioning-action '
'<a class="btn cms-form-get-method cms-versioning-action-btn '
'cms-versioning-action-revert '
'js-versioning-action '
'js-versioning-keep-sideframe" '
'href="%s" '
'title="Revert">'
Expand Down

0 comments on commit 7b60aca

Please sign in to comment.