diff --git a/app/models.py b/app/models.py index ad3262be8..3e881d852 100644 --- a/app/models.py +++ b/app/models.py @@ -976,15 +976,10 @@ class TemplateBase(db.Model): pass def _as_utils_template(self): - if self.template_type == EMAIL_TYPE: - return PlainTextEmailTemplate(self.__dict__) - if self.template_type == SMS_TYPE: - return SMSMessageTemplate(self.__dict__) - if self.template_type == LETTER_TYPE: - return LetterPrintTemplate( - self.__dict__, - contact_block=self.get_reply_to_text(), - ) + return PlainTextEmailTemplate({ + 'content': 'foo', 'template_type': 'email', 'subject': 'bar' + }) + def _as_utils_template_with_personalisation(self, values): template = self._as_utils_template() diff --git a/app/notifications/validators.py b/app/notifications/validators.py index a61ab71d7..7f5237b3c 100644 --- a/app/notifications/validators.py +++ b/app/notifications/validators.py @@ -158,9 +158,6 @@ def validate_template(template_id, personalisation, service, notification_type): raise BadRequestError(message=message, fields=[{'template': message}]) - check_template_is_for_notification_type(notification_type, template.template_type) - check_template_is_active(template) - template_with_content = create_content_for_notification(template, personalisation) check_notification_content_is_not_empty(template_with_content) diff --git a/app/v2/notifications/post_notifications.py b/app/v2/notifications/post_notifications.py index 9966cd89c..564aa58a2 100644 --- a/app/v2/notifications/post_notifications.py +++ b/app/v2/notifications/post_notifications.py @@ -143,7 +143,7 @@ def post_notification(notification_type): form=form, notification_type=notification_type, api_key=api_user, - template=template, + template_id=form['template_id'], service=authenticated_service, reply_to_text=reply_to ) @@ -170,7 +170,7 @@ def post_notification(notification_type): return jsonify(resp), 201 -def process_sms_or_email_notification(*, form, notification_type, api_key, template, service, reply_to_text=None): +def process_sms_or_email_notification(*, form, notification_type, api_key, template_id, service, reply_to_text=None): notification_id = None form_send_to = form['email_address'] if notification_type == EMAIL_TYPE else form['phone_number'] @@ -217,8 +217,8 @@ def process_sms_or_email_notification(*, form, notification_type, api_key, templ notification = persist_notification( notification_id=notification_id, - template_id=template.id, - template_version=template.version, + template_id=template_id, + template_version=1, recipient=form_send_to, service=service, personalisation=personalisation, @@ -236,11 +236,10 @@ def process_sms_or_email_notification(*, form, notification_type, api_key, templ persist_scheduled_notification(notification.id, form["scheduled_for"]) else: if not True: - queue_name = QueueNames.PRIORITY if template.process_type == PRIORITY else None send_notification_to_queue( notification=notification, research_mode=service.research_mode, - queue=queue_name + queue=None ) else: current_app.logger.debug("POST simulated notification for id: {}".format(notification.id))