def feedback(request): if askbot_settings.FEEDBACK_MODE == 'auth-only': if request.user.is_anonymous(): message = _('Please sign in or register to send your feedback') # request.user.message_set.create(message=message) django_messages.info(request, message) redirect_url = get_login_url() + '?next=' + request.path return redirect(redirect_url) elif askbot_settings.FEEDBACK_MODE == 'disabled': raise Http404 data = {'page_class': 'meta'} form = None if request.method == "POST": form = FeedbackForm(user=request.user, data=request.POST) if form.is_valid(): data = { 'message': form.cleaned_data['message'], 'name': form.cleaned_data.get('name'), 'ip_addr': request.META.get('REMOTE_ADDR', _('unknown')), 'user': request.user } if request.user.is_authenticated(): data['email'] = request.user.email else: data['email'] = form.cleaned_data.get('email', None) email = FeedbackEmail(data) if askbot_settings.FEEDBACK_EMAILS: recipients = re.split('\s*,\s*', askbot_settings.FEEDBACK_EMAILS) email.send(recipients) else: email.send(get_moderators()) message = _('Thanks for the feedback!') # request.user.message_set.create(message=message) django_messages.info(request, message) return redirect(get_next_url(request)) else: form = FeedbackForm(user=request.user, initial={'next': get_next_url(request)}) data['form'] = form return render(request, 'feedback.jinja', data)
def feedback(request): if askbot_settings.FEEDBACK_MODE == 'auth-only': if request.user.is_anonymous(): message = _('Please sign in or register to send your feedback') request.user.message_set.create(message=message) redirect_url = get_login_url() + '?next=' + request.path return HttpResponseRedirect(redirect_url) elif askbot_settings.FEEDBACK_MODE == 'disabled': raise Http404 data = {'page_class': 'meta'} form = None if request.method == "POST": form = FeedbackForm(user=request.user, data=request.POST) if form.is_valid(): data = { 'message': form.cleaned_data['message'], 'name': form.cleaned_data.get('name'), 'ip_addr': request.META.get('REMOTE_ADDR', _('unknown')), 'user': request.user } if request.user.is_authenticated(): data['email'] = request.user.email else: data['email'] = form.cleaned_data.get('email', None) email = FeedbackEmail(data) if askbot_settings.FEEDBACK_EMAILS: recipients = re.split('\s*,\s*', askbot_settings.FEEDBACK_EMAILS) email.send(recipients) else: email.send(get_moderators()) message = _('Thanks for the feedback!') request.user.message_set.create(message=message) return HttpResponseRedirect(get_next_url(request)) else: form = FeedbackForm( user=request.user, initial={'next':get_next_url(request)} ) data['form'] = form return render(request, 'feedback.html', data)
def feedback(request): if askbot_settings.FEEDBACK_MODE == 'auth-only': if request.user.is_anonymous: message = _('Please sign in or register to send your feedback') request.user.message_set.create(message=message) redirect_url = get_login_url() + '?next=' + request.path return HttpResponseRedirect(redirect_url) elif askbot_settings.FEEDBACK_MODE == 'disabled': raise Http404 data = {'page_class': 'meta'} form = None if request.method == "POST": form = FeedbackForm(user=request.user, data=request.POST) if form.is_valid(): data = { 'message': form.cleaned_data['message'], 'name': form.cleaned_data.get('name'), 'ip_addr': request.META.get('REMOTE_ADDR', _('unknown')), 'user': request.user } if request.user.is_authenticated: data['email'] = request.user.email else: data['email'] = form.cleaned_data.get('email', None) email = FeedbackEmail(data) email.send(get_users_by_role('recv_feedback')) message = _('Thanks for the feedback!') request.user.message_set.create(message=message) return HttpResponseRedirect(get_next_url(request)) else: form = FeedbackForm( user=request.user, initial={'next':get_next_url(request)} ) data['form'] = form return render(request, 'feedback.html', data)