I want to manually approve reports for clients after they have agreed to terms. For this I want to email to be sent to myself when client clicks "accept". I get the following error instead:
The view accounts.views.TermsView didn't return an HttpResponse object. It returned None instead.
Have searched for the same error here, but failed to solve with these. Sorry, new programmer here.
views.py
class TermsView(TemplateView):
template_name = "accounts/terms_of_service.html"
...
def post(self, *args, **kwargs):
self.request.user.terms_accepted = timezone.now()
self.request.user.save(update_fields=["terms_accepted"])
def send_mail(self):
messages.add_message(
self.request,
messages.SUCCESS,
_("Thank you! We will contact you as soon as possible."),
)
send_terms_agreed_reports(self.request.company, self.request.user)
return redirect("stays:dashboard")
emails.py
def send_terms_agreed_reports(company, user):
try:
email_subject = "New company wants to use reports"
return send_email(
settings.TERMS_AGREED_ENABLE_REPORTS,
email_subject,
"emails/terms_agreed_reports.html",
{"company": company.name, "reg_code": company.reg_code, "name": user.name, "email": user.email,
"phone": user.phone},
)
except Exception:
logger.exception("Could not send message")