kopia lustrzana https://github.com/wagtail/wagtail
Add ability to hide 'Submit for Moderation' in action menu using setting WAGTAIL_MODERATION_ENABLED. When set to false, SubmitForModerationMenuItem method is_shown returns false (#5574)
rodzic
1b2dadc429
commit
a7b470bc9d
|
@ -19,6 +19,7 @@ Changelog
|
|||
* Add `WAGTAIL_EMAIL_MANAGEMENT_ENABLED` setting to determine whether users can change their email address (Janne Alatalo)
|
||||
* Recognise Soundcloud artist URLs as embeddable (Kiril Staikov)
|
||||
* Add `WAGTAILDOCS_SERVE_METHOD` setting to determine how document downloads will be linked to and served (Tobias McNulty, Matt Westcott)
|
||||
* Add `WAGTAIL_MODERATION_ENABLED` setting to enable / disable the 'Submit for Moderation' option (Jacob Topp-Mugglestone)
|
||||
* Fix: Added line breaks to long filenames on multiple image / document uploader (Kevin Howbrook)
|
||||
* Fix: Added https support for Scribd oEmbed provider (Rodrigo)
|
||||
* Fix: Changed StreamField group labels color so labels are visible (Catherine Farman)
|
||||
|
|
|
@ -406,6 +406,7 @@ Contributors
|
|||
* Saptak Sengupta
|
||||
* Dawid Bugajewski
|
||||
* Dawn Wages
|
||||
* Jacob Topp-Mugglestone
|
||||
|
||||
Translators
|
||||
===========
|
||||
|
|
|
@ -239,6 +239,14 @@ Allows the default ``LoginForm`` to be extended with extra fields.
|
|||
If a user has not uploaded a profile picture, Wagtail will look for an avatar linked to their email address on gravatar.com. This setting allows you to specify an alternative provider such as like robohash.org, or can be set to ``None`` to disable the use of remote avatars completely.
|
||||
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
WAGTAIL_MODERATION_ENABLED = True
|
||||
|
||||
Changes whether the Submit for Moderation button is displayed in the action menu.
|
||||
|
||||
|
||||
|
||||
Images
|
||||
------
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ Other features
|
|||
* Add ``WAGTAIL_EMAIL_MANAGEMENT_ENABLED`` setting to determine whether users can change their email address (Janne Alatalo)
|
||||
* Recognise Soundcloud artist URLs as embeddable (Kiril Staikov)
|
||||
* Add ``WAGTAILDOCS_SERVE_METHOD`` setting to determine how document downloads will be linked to and served (Tobias McNulty, Matt Westcott)
|
||||
* Add ``WAGTAIL_MODERATION_ENABLED`` setting to enable / disable the 'Submit for Moderation' option (Jacob Topp-Mugglestone)
|
||||
|
||||
|
||||
Bug fixes
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
"""Handles rendering of the list of actions in the footer of the page create/edit views."""
|
||||
|
||||
from django.conf import settings
|
||||
from django.forms import Media, MediaDefiningClass
|
||||
from django.template.loader import render_to_string
|
||||
from django.urls import reverse
|
||||
|
@ -79,7 +80,10 @@ class SubmitForModerationMenuItem(ActionMenuItem):
|
|||
name = 'action-submit'
|
||||
|
||||
def is_shown(self, request, context):
|
||||
if context['view'] == 'create':
|
||||
WAGTAIL_MODERATION_ENABLED = getattr(settings, 'WAGTAIL_MODERATION_ENABLED', True)
|
||||
if not WAGTAIL_MODERATION_ENABLED:
|
||||
return False
|
||||
elif context['view'] == 'create':
|
||||
return True
|
||||
elif context['view'] == 'edit':
|
||||
return not context['page'].locked
|
||||
|
|
|
@ -6,6 +6,7 @@ from django.contrib.auth.models import Group, Permission
|
|||
from django.core import mail
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
|
||||
|
@ -666,6 +667,21 @@ class TestPageCreation(TestCase, WagtailTestUtils):
|
|||
# page should be created
|
||||
self.assertTrue(Page.objects.filter(title="New page!").exists())
|
||||
|
||||
def test_display_moderation_button_by_default(self):
|
||||
"""
|
||||
Tests that by default the "Submit for Moderation" button is shown in the action menu.
|
||||
"""
|
||||
response = self.client.get(reverse('wagtailadmin_pages:add', args=('tests', 'simplepage', self.root_page.id)))
|
||||
self.assertContains(response, '<input type="submit" name="action-submit" value="Submit for moderation" class="button" />')
|
||||
|
||||
@override_settings(WAGTAIL_MODERATION_ENABLED=False)
|
||||
def test_hide_moderation_button(self):
|
||||
"""
|
||||
Tests that if WAGTAIL_MODERATION_ENABLED is set to False, the "Submit for Moderation" button is not shown.
|
||||
"""
|
||||
response = self.client.get(reverse('wagtailadmin_pages:add', args=('tests', 'simplepage', self.root_page.id)))
|
||||
self.assertNotContains(response, '<input type="submit" name="action-submit" value="Submit for moderation" class="button" />')
|
||||
|
||||
|
||||
class TestPerRequestEditHandler(TestCase, WagtailTestUtils):
|
||||
fixtures = ['test.json']
|
||||
|
|
Ładowanie…
Reference in New Issue