Skip to content
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

Feature/add burger menu to changelist #83

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
Changelog
=========

* feat: Added support for burger menu in actions column of changelist view.

1.2.0 (2024-05-16)
==========
* Python 3.10 support added
* Django 4.2 support added
* Django < 3.2 support removed


1.1.0 (2022-02-22)
==================
* Python 3.8, 3.9 support added
Expand Down
8 changes: 8 additions & 0 deletions djangocms_url_manager/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,11 @@ def change_view(self, request, object_id, form_url='', extra_context=None):
return super().change_view(
request, object_id, form_url, extra_context=extra_context,
)

def changelist_view(self, request, *args, extra_context=None, **kwargs):
extra_context = extra_context or {}
# Provide additional context to the changelist view:
extra_context['is_versioning_enabled'] = is_versioning_enabled()
return super().changelist_view(
request, *args, extra_context=extra_context, **kwargs
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{% extends "admin/change_list.html" %}
{% load cms_static static %}

{% block extrahead %}
{{ block.super }}

{% if is_versioning_enabled %}
{# INFO: To avoid conflicts with adminstyle css we need to add styles here #}
{# instead of inside "extrastyle" block or admin Media class. #}
<link rel="stylesheet" href="{% static_with_version 'cms/css/cms.base.css' %}">
<link rel="stylesheet" href="{% static_with_version 'cms/css/cms.pagetree.css' %}">

{# INFO: versioning_static_url_prefix variable is used in versioning actions.js #}
<script>
let versioning_static_url_prefix = "{% static "djangocms_versioning/" %}";
</script>
{% endif %}
{% endblock extrahead %}
34 changes: 34 additions & 0 deletions tests/test_admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
from unittest import skipUnless

Check failure on line 1 in tests/test_admin.py

View workflow job for this annotation

GitHub Actions / isort

Imports are incorrectly sorted and/or formatted.

from django.shortcuts import reverse

from djangocms_url_manager.test_utils.factories import (

Check failure on line 5 in tests/test_admin.py

View workflow job for this annotation

GitHub Actions / flake8

'djangocms_url_manager.test_utils.factories.UrlFactory' imported but unused
UrlFactory,
)
from .base import BaseUrlTestCase


Expand Down Expand Up @@ -70,3 +75,32 @@
)

self.assertEqual(results.count(), 0)


class UrlAdminChangeListViewTestCase(BaseUrlTestCase):

Check warning on line 81 in tests/test_admin.py

View workflow job for this annotation

GitHub Actions / flake8

blank line contains whitespace
@skipUnless(
BaseUrlTestCase.is_versioning_enabled(), "Test only relevant if versioning enabled."
)
def test_get_burger_menu_on_changelist_view(self):
"""
Verify that burger menu exists in actions column on changelist view.
With the exception of preview & edit actions, a burger menu should be created for
all changelist actions if UrlAdmin has inherited from ExtendedVersionAdminMixin.
"""

Check warning on line 91 in tests/test_admin.py

View workflow job for this annotation

GitHub Actions / flake8

blank line contains whitespace
# Move this to a setup routine if more than one function uses it.
self.client.force_login(self.superuser)

# Import directly into function as only used here.
from bs4 import BeautifulSoup

list_url = reverse(
"admin:djangocms_url_manager_url_changelist"
)
response = self.client.get(list_url)

# Parse returned html:
soup = BeautifulSoup(str(response.content, response.charset), features="lxml")
# Assert / verify find_all() does not return an empty string:
self.assertTrue(soup.find_all("a", class_="cms-versioning-action-btn"))
Loading