From 39937715fb5f125220372d01d953f13c4bed8d08 Mon Sep 17 00:00:00 2001 From: Jonathan Sundqvist Date: Fri, 11 Oct 2019 15:30:50 +0200 Subject: [PATCH] Make it possible to add collection from pagecontent admin --- djangocms_pageadmin/admin.py | 19 ++++++++++++------- setup.py | 2 ++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/djangocms_pageadmin/admin.py b/djangocms_pageadmin/admin.py index 0e7b931..71812ec 100644 --- a/djangocms_pageadmin/admin.py +++ b/djangocms_pageadmin/admin.py @@ -21,6 +21,7 @@ from cms.signals.apphook import set_restart_trigger from cms.toolbar.utils import get_object_preview_url +from djangocms_moderation.admin_actions import add_item_to_unpublish_collection from djangocms_version_locking.models import VersionLock from djangocms_version_locking.helpers import version_is_locked from djangocms_versioning.admin import VersioningAdminMixin @@ -32,6 +33,10 @@ from .forms import DuplicateForm from .helpers import proxy_model +# TODO pageadmin should be usable without moderation and versioning. +# or atleast it should be usable without moderation. +USING_MODERATION = True + require_POST = method_decorator(require_POST) @@ -47,6 +52,9 @@ class PageContentAdmin(VersioningAdminMixin, DefaultPageContentAdmin): "state", "modified_date", ] + actions = [ + a for a in [add_item_to_unpublish_collection] if USING_MODERATION + ] ordering = ['-versions__modified'] search_fields = ("title",) @@ -93,7 +101,6 @@ def get_version(self, obj): def state(self, obj): version = self.get_version(obj) return version.get_state_display() - state.short_description = _("state") def url(self, obj): @@ -106,7 +113,6 @@ def url(self, obj): url = reverse("pages-details-by-slug", kwargs={"slug": path}) if url is not None: return format_html('{url}', url=url) - url.short_description = _("url") def get_title(self, obj): @@ -116,13 +122,11 @@ def get_title(self, obj): lock=self.is_locked(obj), title=obj.title, ) - get_title.short_description = _("title") def author(self, obj): version = self.get_version(obj) return version.created_by - author.short_description = _("author") author.admin_order_field = "versions__created_by" @@ -140,21 +144,22 @@ def is_home(self, obj): def modified_date(self, obj): version = self.get_version(obj) return version.modified - modified_date.short_description = _("modified date") modified_date.admin_order_field = "versions__modified" def get_list_actions(self): - return [ + actions = [ self._set_home_link, self._get_preview_link, self._get_edit_link, self._get_duplicate_link, - self._get_unpublish_link, self._get_manage_versions_link, self._get_basic_settings_link, self._get_advanced_settings_link, ] + if not USING_MODERATION: + actions.insert(4, self._get_unpublish_link) + return actions def _get_preview_link(self, obj, request, disabled=False): return render_to_string( diff --git a/setup.py b/setup.py index 1fe5768..c839684 100644 --- a/setup.py +++ b/setup.py @@ -9,6 +9,7 @@ "django-treebeard>=4.3", "djangocms_versioning", "djangocms_version_locking", + "djangocms-moderation" ] TESTS_REQUIRE = [ @@ -42,6 +43,7 @@ dependency_links=[ "http://github.com/divio/django-cms/tarball/release/4.0.x#egg=django-cms-4.0.0", "http://github.com/divio/djangocms-versioning/tarball/master#egg=djangocms-versioning-0.0.23", + "http://github.com/divio/djangocms-moderation/tarball/release/1.0.x#egg=djangocms-moderation-1.0.22", "http://github.com/FidelityInternational/djangocms-version-locking/tarball/master#egg=djangocms-version-locking-0.0.13" ] )