コード例 #1
0
    def create(data) -> (FeedbackForm, int):
        """
        Create "Feedback".
        :param data: data for the FeedbackForm.
        :return: Form and status code (200/400).
        """
        form = FeedbackForm(data)

        if form.is_valid():
            form.save()
            return form, 200
        return form, 400
コード例 #2
0
ファイル: views.py プロジェクト: rohtshrma/fitness_with_tanu
def feedback(request):
    if request.method == 'POST':
        form = FeedbackForm(request.POST)
        if form.is_valid():
            selfEmail(request)
            form.save()
            return HttpResponseRedirect(reverse('home'))
        mailform = MailForm(request.POST)
        if mailform.is_valid():
            mailform.save()
        return HttpResponseRedirect(reverse('home'))
    else:
        form = FeedbackForm()
        mailform = MailForm()
        return render(request, 'index.html', {'mailform': mailform})
コード例 #3
0
ファイル: views.py プロジェクト: sertac/freedjangohosting.com
def feedback(request,host_id):
    host=get_object_or_404(Hosting,id=host_id)
    if request.method == "POST":
         form = FeedbackForm(data=request.POST)
         if form.is_valid():
              j=form.save(commit=False)
              j.hosting=host
              j.ip=get_client_ip(request)
              j.email=form.cleaned_data['email']
              j.name=form.cleaned_data['name']
              j.comment=form.cleaned_data['comment']
              j.save()
              messages.add_message(request, messages.INFO, 'Thank you.Your feedback is sent !')
              return HttpResponseRedirect('/')
    else:
         form = FeedbackForm()
    return render_to_response('app/feedback.html', context_instance=RequestContext(request, {'form': form,'host':host}))
コード例 #4
0
ファイル: views.py プロジェクト: yngcan/freedjangohosting.com
def feedback(request, host_id):
    host = get_object_or_404(Hosting, id=host_id)
    if request.method == "POST":
        form = FeedbackForm(data=request.POST)
        if form.is_valid():
            j = form.save(commit=False)
            j.hosting = host
            j.ip = get_client_ip(request)
            j.email = form.cleaned_data['email']
            j.name = form.cleaned_data['name']
            j.comment = form.cleaned_data['comment']
            j.save()
            messages.add_message(request, messages.INFO,
                                 'Thank you.Your feedback is sent !')
            return HttpResponseRedirect('/')
    else:
        form = FeedbackForm()
    return render_to_response('app/feedback.html',
                              context_instance=RequestContext(
                                  request, {
                                      'form': form,
                                      'host': host
                                  }))