当前位置: 首页>>代码示例>>Python>>正文


Python FeedbackForm.is_valid方法代码示例

本文整理汇总了Python中forms.FeedbackForm.is_valid方法的典型用法代码示例。如果您正苦于以下问题:Python FeedbackForm.is_valid方法的具体用法?Python FeedbackForm.is_valid怎么用?Python FeedbackForm.is_valid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在forms.FeedbackForm的用法示例。


在下文中一共展示了FeedbackForm.is_valid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import is_valid [as 别名]
    def post(self, request, *args, **kwargs):
        form = FeedbackForm(data=request.POST)

        if form.is_valid():
            data = form.cleaned_data

            feedback_message = FeedbackMessage()
            feedback_message.type = data.get('type')
            feedback_message.subject = data.get('subject')
            feedback_message.content = data.get('content')
            feedback_message.user = request.user
            feedback_message.save()

            requester = '[email protected]'
            if '@' in feedback_message.user.email:
                requester = feedback_message.user.email

            message = (u"[FEEDBACK ADHOC] {0}: {1}".format(feedback_message.type.capitalize(), feedback_message.subject),
                       u"{0}\n- - - - - - - - - -\nFrom user: {1}".format(feedback_message.content,
                                                                          feedback_message.user.username,
                                                                          ),
                       requester,
                       getattr(settings, 'EMAIL_FOR', None),
                       )

            send_mail(*message, fail_silently=False)

            return HttpResponse('true')
        else:
            context = super(FeedbackView, self).get_context_data(**kwargs)
            context.update({
                'form': form,
            })
            return self.render_to_response(context)
开发者ID:Bl3f,项目名称:django-feedback,代码行数:36,代码来源:views.py

示例2: create

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import is_valid [as 别名]
def create(request):
    username = None
    group = 'teacher'
    
    if request.user.is_authenticated():
        username = request.user.username
        if request.user.has_perm('feedback.add_feedback'):
            group = 'parent'
            
    if request.POST:
        form = FeedbackForm(request.POST)
        if form.is_valid():
            # this saves the form submission data, but doesn't submit it to the server yet
            # It is needed so that we can set the parent ID on the model data before final submission
            fb = form.save(commit=False)
            fb.sentByParent = request.user
            fb.save()
            
            return HttpResponseRedirect('/feedback/parent_view/')
        
    else:
        form = FeedbackForm()
        
        args = {}
        args.update(csrf(request))
        
        args['form'] = form
        args['username'] = username
        args['group'] = group
        
        return render_to_response('create_feedback.html', args)
开发者ID:kblauer,项目名称:kinder-updates,代码行数:33,代码来源:views.py

示例3: feedback

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import is_valid [as 别名]
def feedback(request):
    """
    sends the feedback modal.
    """
    logged_in = True

    # CHECKS:
    #   i) user is logged in
    #   ii) request is either ajax for requesting feedback modal
    #   iii) request is a POST request for submitting feedback
    # else error
    if (not request.user.is_authenticated()) or \
            (not request.is_ajax() and not request.method == "POST"):
        return HttpResponse("Please login and go to the main page.")

    form = FeedbackForm()
    if request.method == 'POST':
        form = FeedbackForm(request.POST)
        if form.is_valid():
            obj = form.save(commit=False)
            obj.user = request.user         # add user
            obj.save()
            messages.success(request, "Thank you for your valuable feedback.")
        return HttpResponseRedirect(reverse('home'))
    return render(request, 'feedback.html',{
        'form': form, 'logged_in': logged_in })
开发者ID:IIIT-Delhi,项目名称:findmystuff,代码行数:28,代码来源:views.py

示例4: contact

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import is_valid [as 别名]
def contact(request):

    if request.POST:
        form = FeedbackForm(request.POST)

        if form.is_valid():

            context = {
                'page_title':"Feedback",
                'name': form.cleaned_data['name'],
                'email': form.cleaned_data['email'],
                'comments': form.cleaned_data['comments'],
            }

            try:
                Feedback.objects.create(name=context['name'], email=context['email'], comments=context['comments'])
            except Exception as e:
                context['error'] = str(e)

            return render(request, 'risk_ratings/contact_thanks.html', context)
    else:
        form = FeedbackForm()

    context = {
            'page_title':"Feedback",
            'feedbacks':Feedback.objects.all(),
            'form': form,
        }

    return render(request, 'risk_ratings/contact.html', context)
开发者ID:ellenbowman,项目名称:Satellite,代码行数:32,代码来源:views.py

示例5: feedback

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import is_valid [as 别名]
def feedback(request):
    '''
    '''
    message = u'Форма обратной связи' 
    if request.method == 'POST':    
        form = FeedbackForm(request.POST) 
   
        if form.is_valid():

            email = render_to_string('feedback/email.html', {'object': form.cleaned_data})
            subject, content = EMAIL_SPLIT_RE.split(email, 1)            
            
            from_email = settings.DEFAULT_FROM_EMAIL                                                               
            to_email = getattr(settings, 'FEEDBACK_EMAILS', [e[1] for e in settings.MANAGERS])     

            msg = EmailMultiAlternatives(subject, content, from_email, to_email)                                   
            msg.content_subtype = "html"                                                                       
            msg.send()
            
            message = u'Ваш вопрос успешно отправлен!'
            form = None
    else:            
        form = FeedbackForm()

    return {
            'form': form,
            'message': message,            
            }
开发者ID:MaratFM,项目名称:Djanym,代码行数:30,代码来源:views.py

示例6: feedback_save

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import is_valid [as 别名]
def feedback_save(request):
    form = FeedbackForm(request.user, data=request.POST.copy() or None)

    if form.is_bound and form.is_valid():
        form.save(request.user) 

    return HttpResponse()
开发者ID:mkramb,项目名称:errorify,代码行数:9,代码来源:views.py

示例7: show_feedback_form

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import is_valid [as 别名]
def show_feedback_form(request):
    if request.method == 'POST':
        form = FeedbackForm(request.POST)
        if form.is_valid():
            form.mail()
            return render_to_response('feedback/thankyou.html', {'form': form})
    else:
        form = FeedbackForm()
    return render_to_response('feedback/feedback.html', {'form': form})
开发者ID:pombredanne,项目名称:django-simple-feedback-1,代码行数:11,代码来源:views.py

示例8: feedback

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import is_valid [as 别名]
def feedback(request):
    feedbackform = FeedbackForm(request.POST)
    if not feedbackform.is_valid():
        return redirect("search")
    else:
        message = feedbackform.cleaned_data["message"]
        email = feedbackform.cleaned_data["email"]
        send_mail("feedback", message, email, ["[email protected]"], fail_silently=True)
        return redirect("feedbackThanks")
开发者ID:Satshabad,项目名称:theBooklistr-website,代码行数:11,代码来源:views.py

示例9: feedback

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import is_valid [as 别名]
def feedback(request):

    form = FeedbackForm(request.POST or None)
    if form.is_valid():
        form.save()

        # TODO: Add message (django.contrib.messages)

        return redirect('/')

    return render(request, 'feedback.html', {'form': form})
开发者ID:nixilla,项目名称:where-is-when-is,代码行数:13,代码来源:views.py

示例10: feedback_view

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import is_valid [as 别名]
def feedback_view(request):
    if request.method == 'POST':
        form = FeedbackForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponse('ok')
        else:
            errors = {}
            for key, value in form.errors.items():
                errors[key] = value[0]
            return HttpResponse(json.dumps(errors))
开发者ID:renkse,项目名称:myapps,代码行数:13,代码来源:views.py

示例11: send_feedback

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import is_valid [as 别名]
def send_feedback(request):
    if request.method == 'POST':
        form = FeedbackForm(request.POST)
        if form.is_valid():
            form.save()
            return render(request, 'guestbook/frontend/thanks.html')
    else:
        form = FeedbackForm()

    return render(request, 'guestbook/frontend/send_feedback.html', {
        'form': form,
    })
开发者ID:VBelozyorov,项目名称:libcms,代码行数:14,代码来源:views.py

示例12: add_feedback

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import is_valid [as 别名]
def add_feedback(request, conference_slug=''):
    if request.method == 'POST':
        form = FeedbackForm(request.POST)

        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('guestbook_index'))
    else:
        form = FeedbackForm()
    return render(request, 'guestbook/feedback_add.html',
                              {'form': form,
                               'module':'guestbook',})
开发者ID:isergey,项目名称:system,代码行数:14,代码来源:views.py

示例13: feedbackcreate

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import is_valid [as 别名]
def feedbackcreate(request):

    form = FeedbackForm(request.POST or None)
    topics = Topic.objects.all()

    if request.method == 'POST':
        if form.is_valid():
            form.save(commit=True)
            return HttpResponseRedirect(reverse('thanks'))
        else:
            return render(request, 'feedback.html', {'form': form, 'topics': topics })

    return render(request, 'feedback.html', {'form': FeedbackForm(), 'topics': topics})
开发者ID:Bauerr,项目名称:geoq,代码行数:15,代码来源:views.py

示例14: edit_feedback

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import is_valid [as 别名]
def edit_feedback(request, id):
    feedback = get_object_or_404(Feedback, id=id)
    if request.method == 'POST':
        form = FeedbackForm(request.POST, instance=feedback)
        if form.is_valid():
            form.save()
            return redirect('guestbook:administration:feedbacks_list')
    else:
        form = FeedbackForm(instance=feedback)

    return render(request, 'guestbook/administration/edit_feedback.html', {
        'form': form,
    })
开发者ID:VBelozyorov,项目名称:libcms,代码行数:15,代码来源:views.py

示例15: edit

# 需要导入模块: from forms import FeedbackForm [as 别名]
# 或者: from forms.FeedbackForm import is_valid [as 别名]
def edit(request, message_id):
    feedback = get_object_or_404(Feedback, id=message_id)
    if request.method == 'POST':
        form = FeedbackForm(request.POST, instance=feedback)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('administration_guestbook_index'))
    else:
        form = FeedbackForm(model_to_dict(feedback),instance=feedback)
    return direct_to_template(request, 'guestbook/administration/edit_message.html',
                              {'form': form,
                               'feedback':feedback,
                               'active_module': 'guestbook'})
开发者ID:isergey,项目名称:system,代码行数:15,代码来源:views.py


注:本文中的forms.FeedbackForm.is_valid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。