Allow user feedback to request email reply back

This commit is contained in:
Lance Edgar 2022-08-17 21:08:54 -05:00
parent 5fb99c54c9
commit 2fde1db83c
4 changed files with 35 additions and 5 deletions

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2021 Lance Edgar # Copyright © 2010-2022 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -58,4 +58,7 @@ class Feedback(colander.Schema):
user_name = colander.SchemaNode(colander.String(), user_name = colander.SchemaNode(colander.String(),
missing=colander.null) missing=colander.null)
please_reply_to = colander.SchemaNode(colander.String(),
missing=colander.null)
message = colander.SchemaNode(colander.String()) message = colander.SchemaNode(colander.String())

View file

@ -5,6 +5,12 @@ let FeedbackForm = {
mixins: [FormPosterMixin], mixins: [FormPosterMixin],
methods: { methods: {
pleaseReplyChanged(value) {
this.$nextTick(() => {
this.$refs.userEmail.focus()
})
},
showFeedback() { showFeedback() {
this.showDialog = true this.showDialog = true
this.$nextTick(function() { this.$nextTick(function() {
@ -18,6 +24,7 @@ let FeedbackForm = {
referrer: this.referrer, referrer: this.referrer,
user: this.userUUID, user: this.userUUID,
user_name: this.userName, user_name: this.userName,
please_reply_to: this.pleaseReply ? this.userEmail : null,
message: this.message.trim(), message: this.message.trim(),
} }
@ -41,5 +48,7 @@ let FeedbackFormData = {
referrer: null, referrer: null,
userUUID: null, userUUID: null,
userName: null, userName: null,
pleaseReply: false,
userEmail: null,
showDialog: false, showDialog: false,
} }

View file

@ -487,7 +487,7 @@
</header> </header>
<section class="modal-card-body"> <section class="modal-card-body">
<p> <p class="block">
Questions, suggestions, comments, complaints, etc. Questions, suggestions, comments, complaints, etc.
<span class="red">regarding this website</span> are <span class="red">regarding this website</span> are
welcome and may be submitted below. welcome and may be submitted below.
@ -516,6 +516,24 @@
</b-input> </b-input>
</b-field> </b-field>
% if request.rattail_config.getbool('tailbone', 'feedback_allows_reply'):
<div class="level">
<div class="level-left">
<div class="level-item">
<b-checkbox v-model="pleaseReply"
@input="pleaseReplyChanged">
Please email me back{{ pleaseReply ? " at: " : "" }}
</b-checkbox>
</div>
<div class="level-item" v-show="pleaseReply">
<b-input v-model="userEmail"
ref="userEmail">
</b-input>
</div>
</div>
</div>
% endif
</section> </section>
<footer class="modal-card-foot"> <footer class="modal-card-foot">

View file

@ -29,9 +29,7 @@ from __future__ import unicode_literals, absolute_import
import os import os
import six import six
from rattail.db import model
from rattail.batch import consume_batch_id from rattail.batch import consume_batch_id
from rattail.mail import send_email
from rattail.util import OrderedDict, simple_error, import_module_path from rattail.util import OrderedDict, simple_error, import_module_path
from rattail.files import resource_path from rattail.files import resource_path
@ -172,6 +170,8 @@ class CommonView(View):
""" """
Generic view to handle the user feedback form. Generic view to handle the user feedback form.
""" """
app = self.get_rattail_app()
model = self.model
schema = Feedback().bind(session=Session()) schema = Feedback().bind(session=Session())
form = forms.Form(schema=schema, request=self.request) form = forms.Form(schema=schema, request=self.request)
if form.validate(newstyle=True): if form.validate(newstyle=True):
@ -180,7 +180,7 @@ class CommonView(View):
data['user'] = Session.query(model.User).get(data['user']) data['user'] = Session.query(model.User).get(data['user'])
data['user_url'] = self.request.route_url('users.view', uuid=data['user'].uuid) data['user_url'] = self.request.route_url('users.view', uuid=data['user'].uuid)
data['client_ip'] = self.request.client_addr data['client_ip'] = self.request.client_addr
send_email(self.rattail_config, 'user_feedback', data=data) app.send_email('user_feedback', data=data)
return {'ok': True} return {'ok': True}
return {'error': "Form did not validate!"} return {'error': "Form did not validate!"}