Skip to content

Commit

Permalink
Merge pull request #666 from plone/revert-fix-email-notification-errors
Browse files Browse the repository at this point in the history
Revert "Standardize errors data structure of email-notification endpo…
  • Loading branch information
tisto committed Feb 4, 2019
2 parents 7f0ff78 + 50470f6 commit 542e05d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 25 deletions.
3 changes: 0 additions & 3 deletions CHANGES.rst
Expand Up @@ -18,9 +18,6 @@ Bugfixes:
and `648 <https://github.com/plone/plone.restapi/issues/648>`_.
[maurits, gforcada]

- Standardize errors data structure of email-notification endpoint.
[cekk]


3.5.0 (2018-11-06)
------------------
Expand Down
2 changes: 1 addition & 1 deletion src/plone/restapi/services/content/tus.py
Expand Up @@ -37,7 +37,7 @@ class UploadOptions(Service):

def reply(self):
for name, value in TUS_OPTIONS_RESPONSE_HEADERS.items():
self.request.response.setHeader(name, value)
self.request.response.setHeader(name, value)
return super(UploadOptions, self).reply()


Expand Down
21 changes: 13 additions & 8 deletions src/plone/restapi/services/email_notification/post.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
from plone.restapi.deserializer import json_body
from plone.restapi.services import Service
from zExceptions import BadRequest
from zope.component import getMultiAdapter
from plone.restapi.deserializer import json_body
from zope.interface import alsoProvides

import plone
Expand All @@ -19,12 +18,18 @@ def reply(self):
subject = data.get('subject', '')

if not sender_from_address or not message:
raise BadRequest('Missing from or message parameters')
self.request.response.setStatus(400)
return dict(error=dict(
type='BadRequest',
message='Missing from or message parameters'))

overview_controlpanel = getMultiAdapter((self.context, self.request),
name='overview-controlpanel')
if overview_controlpanel.mailhost_warning():
raise BadRequest('MailHost is not configured.')
self.request.response.setStatus(400)
return dict(error=dict(
type='BadRequest',
message='MailHost is not configured.'))

# Disable CSRF protection
if 'IDisableCSRFProtection' in dir(plone.protect.interfaces):
Expand All @@ -36,10 +41,10 @@ def reply(self):

contact_info_view.send_message(
dict(
message=message,
subject=subject,
sender_from_address=sender_from_address,
sender_fullname=sender_fullname
message=message,
subject=subject,
sender_from_address=sender_from_address,
sender_fullname=sender_fullname
)
)

Expand Down
13 changes: 0 additions & 13 deletions src/plone/restapi/tests/test_services_email_notification.py
Expand Up @@ -49,19 +49,6 @@ def setUp(self):
def tearDown(self):
self.api_session.close()

def test_email_notification_missing_parameters(self):
response = self.api_session.post(
'/@email-notification',
json={
'message': 'Just want to say hi.'
})
transaction.commit()
self.assertEqual(response.status_code, 400)
self.assertEqual(self.mailhost.messages, [])
error = response.json()
self.assertEqual(error['message'],
'Missing from or message parameters')

def test_email_notification(self):
response = self.api_session.post(
'/@email-notification',
Expand Down

0 comments on commit 542e05d

Please sign in to comment.