Exemplo n.º 1
0
def feedback(request):
    if request.method == "POST":
        form = FeedbackForm(request.user, data=request.POST)
        if form.is_valid():
            context = {
                'user':
                request.user,
                'email':
                request.user.is_authenticated() and request.user.email
                or form.cleaned_data.get('email', None),
                'message':
                form.cleaned_data['message'],
                'name':
                request.user.is_authenticated() and request.user.username
                or form.cleaned_data.get('name', None),
                'ip':
                request.META['REMOTE_ADDR'],
            }

            recipients = User.objects.filter(is_superuser=True)
            send_template_email(recipients, "notifications/feedback.html",
                                context)

            msg = _('Thanks for the feedback!')
            request.user.message_set.create(message=msg)
            return HttpResponseRedirect(get_next_url(request))
    else:
        form = FeedbackForm(request.user,
                            initial={'next': get_next_url(request)})

    return render_to_response('feedback.html', {'form': form},
                              context_instance=RequestContext(request))
Exemplo n.º 2
0
def feedback(request):
    if request.method == "POST":
        form = FeedbackForm(request.POST)
        if form.is_valid():
            context = {'user': request.user}

            if not request.user.is_authenticated:
                context['email'] = form.cleaned_data.get('email', None)
            context['message'] = form.cleaned_data['message']
            context['name'] = form.cleaned_data.get('name', None)

            recipients = [(adm.username, adm.email)
                          for adm in User.objects.filter(is_superuser=True)]

            send_email(
                settings.EMAIL_SUBJECT_PREFIX +
                _("Feedback message from %(site_name)s") %
                {'site_name': settings.APP_SHORT_NAME}, recipients,
                "notifications/feedback.html", context)

            msg = _('Thanks for the feedback!')
            request.user.message_set.create(message=msg)
            return HttpResponseRedirect(get_next_url(request))
    else:
        form = FeedbackForm(initial={'next': get_next_url(request)})

    return render_to_response('feedback.html', {'form': form},
                              context_instance=RequestContext(request))
Exemplo n.º 3
0
def feedback(request):
    """

    """
    if request.method == "POST":
        form = FeedbackForm(request.user, data=request.POST)
        if form.is_valid():
            context = {
                 'user': request.user,
                 'email': request.user.is_authenticated() and request.user.email or form.cleaned_data.get('email', None),
                 'message': form.cleaned_data['message'],
                 'name': request.user.is_authenticated() and request.user.username or form.cleaned_data.get('name', None),
                 'ip': request.META['REMOTE_ADDR'],
            }

            recipients = User.objects.filter(is_superuser=True)
            send_template_email(recipients, "notifications/feedback.html", context)

            msg = _('Thanks for the feedback!')
            request.user.message_set.create(message=msg, level=messages_extends.SUCCESS_PERSISTENT)
            return HttpResponseRedirect(get_next_url(request))
    else:
        form = FeedbackForm(request.user, initial={'next':get_next_url(request)})

    return render_to_response('feedback.html', {'form': form}, context_instance=RequestContext(request))
Exemplo n.º 4
0
def feedback(request):
    data = {}
    form = None
    if request.method == "POST":
        form = FeedbackForm(request.POST)
        if form.is_valid():
            if not request.user.is_authenticated:
                data['email'] = form.cleaned_data.get('email',None)
            data['message'] = form.cleaned_data['message']
            data['name'] = form.cleaned_data.get('name',None)
            message = render_to_response('feedback_email.txt',data,context_instance=RequestContext(request))
            mail_admins(_('Q&A forum feedback'), message)
            msg = _('Thanks for the feedback!')
            request.user.message_set.create(message=msg)
            return HttpResponseRedirect(get_next_url(request))
    else:
        form = FeedbackForm(initial={'next':get_next_url(request)})

    data['form'] = form
    return render_to_response('feedback.html', data, context_instance=RequestContext(request))
Exemplo n.º 5
0
def feedback(request):
    if request.method == "POST":
        form = FeedbackForm(request.POST)
        if form.is_valid():
            context = {'user': request.user}

            if not request.user.is_authenticated:
                context['email'] = form.cleaned_data.get('email',None)
            context['message'] = form.cleaned_data['message']
            context['name'] = form.cleaned_data.get('name',None)

            recipients = [(adm.username, adm.email) for adm in User.objects.filter(is_superuser=True)]

            send_email(settings.EMAIL_SUBJECT_PREFIX + _("Feedback message from %(site_name)s") % {'site_name': settings.APP_SHORT_NAME},
                       recipients, "notifications/feedback.html", context)
            
            msg = _('Thanks for the feedback!')
            request.user.message_set.create(message=msg)
            return HttpResponseRedirect(get_next_url(request))
    else:
        form = FeedbackForm(initial={'next':get_next_url(request)})

    return render_to_response('feedback.html', {'form': form}, context_instance=RequestContext(request))
Exemplo n.º 6
0
Arquivo: meta.py Projeto: ehudtal/osqa
def feedback(request):
    if request.method == "POST":
        form = FeedbackForm(request.user, data=request.POST)
        if form.is_valid():
            context = {
                "user": request.user,
                "email": request.user.is_authenticated() and request.user.email or form.cleaned_data.get("email", None),
                "message": form.cleaned_data["message"],
                "name": request.user.is_authenticated()
                and request.user.username
                or form.cleaned_data.get("name", None),
                "ip": request.META["REMOTE_ADDR"],
            }

            recipients = User.objects.filter(is_superuser=True)
            send_template_email(recipients, "notifications/feedback.html", context)

            msg = _("Thanks for the feedback!")
            messages.info(request, msg)
            return HttpResponseRedirect(get_next_url(request))
    else:
        form = FeedbackForm(request.user, initial={"next": get_next_url(request)})

    return render_to_response("feedback.html", {"form": form}, context_instance=RequestContext(request))