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

fix: Replace SortableAdminMixin by SortableAdminBase for WorkflowAdmin #279

Merged
merged 7 commits into from
Aug 28, 2024
Merged
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: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:
dj50_cms41.txt,
dj42_cms41.txt,
dj42_cms40.txt,
dj32_cms40.txt,
]
os: [
ubuntu-20.04,
Expand All @@ -40,7 +39,7 @@ jobs:
python setup.py install

- name: Run coverage
run: coverage run setup.py test
run: coverage run ./tests/settings.py

- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v4
4 changes: 2 additions & 2 deletions djangocms_moderation/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from cms.toolbar.utils import get_object_preview_url
from cms.utils.helpers import is_editable_model

from adminsortable2.admin import SortableAdminMixin, SortableInlineAdminMixin
from adminsortable2.admin import SortableAdminBase, SortableInlineAdminMixin
from treebeard.admin import TreeAdmin

from . import constants, signals
Expand Down Expand Up @@ -1011,7 +1011,7 @@ def get_extra(self, request, obj=None, **kwargs):


@admin.register(Workflow)
class WorkflowAdmin(SortableAdminMixin, admin.ModelAdmin):
class WorkflowAdmin(SortableAdminBase, admin.ModelAdmin):
inlines = [WorkflowStepInline]
list_display = ["name", "is_default"]
fields = [
Expand Down
15 changes: 15 additions & 0 deletions tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from django.test.client import RequestFactory
from django.urls import reverse

from cms.utils.urlutils import admin_reverse

from djangocms_versioning.test_utils import factories

from djangocms_moderation import conf, constants
Expand Down Expand Up @@ -425,3 +427,16 @@ def test_tree_admin_burger_menu_present(self):
response = self.client.get(url)

self.assertContains(response, '/static/djangocms_moderation/js/burger.js')

def test_workflow_admin_renders_correctly(self):
url = admin_reverse("djangocms_moderation_workflow_change", args=(self.wf.pk,))

with self.login_user_context(self.get_superuser()):
result = self.client.get(url, follow=True)

self.assertEqual(result.status_code, 200)
self.assertContains(result, self.wf.name)

# django-admin-sortable2 injected its inputs
self.assertContains(result, '<script src="/static/adminsortable2/js/adminsortable2.min.js"></script>')
self.assertContains(result, '<input type="hidden" name="steps-0-id"')
Loading