kopia lustrzana https://github.com/wagtail/wagtail
Include submitter in workflow submitted email notification (#6976)
rodzic
2fe5683744
commit
255a1e8641
|
@ -16,6 +16,7 @@ Changelog
|
|||
* Add support to SVG icons for ``SearchArea`` subclasses in ``register_admin_search_area`` (Thibaud Colas)
|
||||
* Add `wagtail.reorder` page audit log action (Storm Heg)
|
||||
* `get_settings` template tag now supports specifying the variable name with `{% get_settings as var %}` (Samir Shah)
|
||||
* Reinstate submitter's name on moderation notification email (Matt Westcott)
|
||||
* Fix: StreamField required status is now consistently handled by the `blank` keyword argument (Matt Westcott)
|
||||
* Fix: Show 'required' asterisks for blocks inside required StreamFields (Matt Westcott)
|
||||
* Fix: Make image chooser "Select format" fields translatable (Helen Chapman, Thibaud Colas)
|
||||
|
|
|
@ -33,6 +33,7 @@ Other features
|
|||
* Add support to SVG icons for ``SearchArea`` subclasses in ``register_admin_search_area`` (Thibaud Colas)
|
||||
* Add specialized ``wagtail.reorder`` page audit log action. This was previously covered by the ``wagtail.move`` action (Storm Heg)
|
||||
* ``get_settings`` template tag now supports specifying the variable name with ``{% get_settings as var %}`` (Samir Shah)
|
||||
* Reinstate submitter's name on moderation notification email (Matt Westcott)
|
||||
|
||||
Bug fixes
|
||||
~~~~~~~~~
|
||||
|
|
|
@ -331,6 +331,11 @@ class WorkflowStateSubmissionEmailNotifier(BaseWorkflowStateEmailNotifier):
|
|||
|
||||
return recipients
|
||||
|
||||
def get_context(self, workflow_state, **kwargs):
|
||||
context = super().get_context(workflow_state, **kwargs)
|
||||
context['requested_by'] = workflow_state.requested_by
|
||||
return context
|
||||
|
||||
|
||||
class BaseGroupApprovalTaskStateEmailNotifier(EmailNotificationMixin, Notifier):
|
||||
"""A base notifier to send email updates for GroupApprovalTask events"""
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
{% extends 'wagtailadmin/notifications/base.html' %}
|
||||
|
||||
{% load i18n %}
|
||||
{% load wagtailadmin_tags i18n %}
|
||||
|
||||
{% block content %}
|
||||
<p>{% blocktrans with workflow=workflow.name title=page.get_admin_display_title %}The page "{{ title }}" has been submitted for moderation to workflow "{{ workflow }}".{% endblocktrans %}</p>
|
||||
{% if requested_by %}
|
||||
<p>{% blocktrans with workflow=workflow.name title=page.get_admin_display_title requester=requested_by|user_display_name %}The page "{{ title }}" has been submitted for moderation to workflow "{{ workflow }}" by {{ requester }}.{% endblocktrans %}</p>
|
||||
{% else %}
|
||||
<p>{% blocktrans with workflow=workflow.name title=page.get_admin_display_title %}The page "{{ title }}" has been submitted for moderation to workflow "{{ workflow }}".{% endblocktrans %}</p>
|
||||
{% endif %}
|
||||
|
||||
<p>
|
||||
{% trans "You can edit the page here:" %} <a href="{{ settings.BASE_URL }}{% url 'wagtailadmin_pages:edit' page.id %}">{{ settings.BASE_URL }}{% url 'wagtailadmin_pages:edit' page.id %}</a>
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
{% extends 'wagtailadmin/notifications/base.txt' %}
|
||||
|
||||
{% load i18n %}
|
||||
{% load wagtailadmin_tags i18n %}
|
||||
|
||||
{% block content %}
|
||||
{% blocktrans with workflow=workflow.name|safe title=page.get_admin_display_title|safe %}The page "{{ title }}" has been submitted for moderation to workflow "{{ workflow }}".{% endblocktrans %}
|
||||
|
||||
{% if requested_by %}{% blocktrans with workflow=workflow.name|safe title=page.get_admin_display_title|safe requester=requested_by|user_display_name|safe %}The page "{{ title }}" has been submitted for moderation to workflow "{{ workflow }}" by {{ requester }}.{% endblocktrans %}
|
||||
{% else %}{% blocktrans with workflow=workflow.name|safe title=page.get_admin_display_title|safe %}The page "{{ title }}" has been submitted for moderation to workflow "{{ workflow }}".{% endblocktrans %}
|
||||
{% endif %}
|
||||
|
||||
{% trans "You can edit the page here:" %} {{ settings.BASE_URL }}{% url 'wagtailadmin_pages:edit' page.id %}
|
||||
|
||||
|
|
|
@ -748,6 +748,27 @@ class TestSubmitToWorkflow(TestCase, WagtailTestUtils):
|
|||
self.assertRegex(response.content.decode('utf-8'), r'Awaiting[\s|\n]+{}'.format(self.page.current_workflow_task.name))
|
||||
self.assertNotContains(response, 'Draft')
|
||||
|
||||
def test_submit_sends_mail(self):
|
||||
self.submit()
|
||||
# 3 emails sent:
|
||||
# - to moderator - submitted for approval in moderation stage test_task_1
|
||||
# - to superuser - submitted for approval in moderation stage test_task_1
|
||||
# - to superuser - submitted to workflow test_workflow
|
||||
self.assertEqual(len(mail.outbox), 3)
|
||||
|
||||
# the 'submitted to workflow' email should include the submitter's name
|
||||
workflow_message = None
|
||||
for msg in mail.outbox:
|
||||
if msg.subject == 'The page "Hello world! (simple page)" has been submitted to workflow "test_workflow"':
|
||||
workflow_message = msg
|
||||
break
|
||||
|
||||
self.assertTrue(workflow_message)
|
||||
self.assertIn(
|
||||
'The page "Hello world! (simple page)" has been submitted for moderation to workflow "test_workflow" by submitter',
|
||||
workflow_message.body
|
||||
)
|
||||
|
||||
@mock.patch.object(EmailMultiAlternatives, 'send', side_effect=IOError('Server down'))
|
||||
def test_email_send_error(self, mock_fn):
|
||||
logging.disable(logging.CRITICAL)
|
||||
|
|
Ładowanie…
Reference in New Issue