Allow user feedback to request email reply back
This commit is contained in:
parent
5fb99c54c9
commit
2fde1db83c
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2021 Lance Edgar
|
||||
# Copyright © 2010-2022 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -58,4 +58,7 @@ class Feedback(colander.Schema):
|
|||
user_name = colander.SchemaNode(colander.String(),
|
||||
missing=colander.null)
|
||||
|
||||
please_reply_to = colander.SchemaNode(colander.String(),
|
||||
missing=colander.null)
|
||||
|
||||
message = colander.SchemaNode(colander.String())
|
||||
|
|
|
@ -5,6 +5,12 @@ let FeedbackForm = {
|
|||
mixins: [FormPosterMixin],
|
||||
methods: {
|
||||
|
||||
pleaseReplyChanged(value) {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.userEmail.focus()
|
||||
})
|
||||
},
|
||||
|
||||
showFeedback() {
|
||||
this.showDialog = true
|
||||
this.$nextTick(function() {
|
||||
|
@ -18,6 +24,7 @@ let FeedbackForm = {
|
|||
referrer: this.referrer,
|
||||
user: this.userUUID,
|
||||
user_name: this.userName,
|
||||
please_reply_to: this.pleaseReply ? this.userEmail : null,
|
||||
message: this.message.trim(),
|
||||
}
|
||||
|
||||
|
@ -41,5 +48,7 @@ let FeedbackFormData = {
|
|||
referrer: null,
|
||||
userUUID: null,
|
||||
userName: null,
|
||||
pleaseReply: false,
|
||||
userEmail: null,
|
||||
showDialog: false,
|
||||
}
|
||||
|
|
|
@ -487,7 +487,7 @@
|
|||
</header>
|
||||
|
||||
<section class="modal-card-body">
|
||||
<p>
|
||||
<p class="block">
|
||||
Questions, suggestions, comments, complaints, etc.
|
||||
<span class="red">regarding this website</span> are
|
||||
welcome and may be submitted below.
|
||||
|
@ -516,6 +516,24 @@
|
|||
</b-input>
|
||||
</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>
|
||||
|
||||
<footer class="modal-card-foot">
|
||||
|
|
|
@ -29,9 +29,7 @@ from __future__ import unicode_literals, absolute_import
|
|||
import os
|
||||
import six
|
||||
|
||||
from rattail.db import model
|
||||
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.files import resource_path
|
||||
|
||||
|
@ -172,6 +170,8 @@ class CommonView(View):
|
|||
"""
|
||||
Generic view to handle the user feedback form.
|
||||
"""
|
||||
app = self.get_rattail_app()
|
||||
model = self.model
|
||||
schema = Feedback().bind(session=Session())
|
||||
form = forms.Form(schema=schema, request=self.request)
|
||||
if form.validate(newstyle=True):
|
||||
|
@ -180,7 +180,7 @@ class CommonView(View):
|
|||
data['user'] = Session.query(model.User).get(data['user'])
|
||||
data['user_url'] = self.request.route_url('users.view', uuid=data['user'].uuid)
|
||||
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 {'error': "Form did not validate!"}
|
||||
|
||||
|
|
Loading…
Reference in a new issue