From 90af8f91b88c6f8e82bfafaf452e923d2ae43224 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Mon, 2 Aug 2021 18:26:15 -0500 Subject: [PATCH] Let feedback forms define their own email key so multiple recipient options may be presented to user, e.g. in public frontend --- tailbone/api/common.py | 3 ++- tailbone/forms/common.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tailbone/api/common.py b/tailbone/api/common.py index c2823ff9..81458c01 100644 --- a/tailbone/api/common.py +++ b/tailbone/api/common.py @@ -104,7 +104,8 @@ class CommonView(APIView): data['user_url'] = '#' # TODO: could get from config? data['client_ip'] = self.request.client_addr - send_email(self.rattail_config, self.feedback_email_key, data=data) + email_key = data['email_key'] or self.feedback_email_key + send_email(self.rattail_config, email_key, data=data) return {'ok': True} return {'error': "Form did not validate!"} diff --git a/tailbone/forms/common.py b/tailbone/forms/common.py index 9cc145dd..26934479 100644 --- a/tailbone/forms/common.py +++ b/tailbone/forms/common.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2019 Lance Edgar +# Copyright © 2010-2021 Lance Edgar # # This file is part of Rattail. # @@ -46,6 +46,9 @@ class Feedback(colander.Schema): """ Form schema for user feedback. """ + email_key = colander.SchemaNode(colander.String(), + missing=colander.null) + referrer = colander.SchemaNode(colander.String()) user = colander.SchemaNode(colander.String(),