Convert user feedback mechanism to use modal dialog

instead of navigating to new page.  this is how it should have been done
to begin with...
This commit is contained in:
Lance Edgar 2017-10-13 08:01:43 -07:00
parent 827cc592b4
commit 8d002f76d2
5 changed files with 143 additions and 6 deletions

View file

@ -50,6 +50,7 @@ class Feedback(fe.Schema):
Form schema for user feedback.
"""
allow_extra_fields = True
referrer = fe.validators.NotEmpty()
user = forms.validators.ValidUser()
user_name = fe.validators.NotEmpty()
message = fe.validators.NotEmpty()
@ -122,9 +123,8 @@ class CommonView(View):
if data['user']:
data['user_url'] = self.request.route_url('users.view', uuid=data['user'].uuid)
send_email(self.rattail_config, 'user_feedback', data=data)
self.request.session.flash("Thank you for your feedback.")
return httpexceptions.HTTPFound(location=form.data['referrer'])
return {'form': forms.FormRenderer(form)}
return {'ok': True}
return {'error': "Form did not validate!"}
def consume_batch_id(self):
"""
@ -176,8 +176,8 @@ class CommonView(View):
config.add_view(cls, attr='about', route_name='mobile.about', renderer='/mobile/about.mako')
# feedback
config.add_route('feedback', '/feedback')
config.add_view(cls, attr='feedback', route_name='feedback', renderer='/feedback.mako')
config.add_route('feedback', '/feedback', request_method='POST')
config.add_view(cls, attr='feedback', route_name='feedback', renderer='json')
# consume batch ID
config.add_tailbone_permission('common', 'common.consume_batch_id',