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


Python forms.FeedbackForm类代码示例

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


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

示例1: create

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,代码行数:31,代码来源:views.py

示例2: post_feedback

def post_feedback(id):
    project = Project.query.get_or_404(id)

    form = FeedbackForm()
    if form.validate():
        issue = Document(form.summary.data, form.description.data)
        feedback = Feedback()
        feedback.project = project
        feedback.id = Feedback.get_id_from_doc(issue, project=project)
        existing_feedback = Feedback.query.get(feedback.id)
        if existing_feedback:
            feedback = existing_feedback

        if form.selected_recommendation.data:
            feedback.selected_recommendation = \
                form.selected_recommendation.data
        if form.confirmed_recommendation.data:
            feedback.confirmed_recommendation = \
                form.confirmed_recommendation.data
        db.session.add(feedback)
        db.session.commit()

        return jsonify(result="success")

    return jsonify(result="error", errors=form.errors), 400
开发者ID:VaclavDedik,项目名称:triager,代码行数:25,代码来源:views.py

示例3: feedback

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,代码行数:28,代码来源:views.py

示例4: post

    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,代码行数:34,代码来源:views.py

示例5: feedback_save

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,代码行数:7,代码来源:views.py

示例6: feedback

def feedback():
    feedbackerrors = []
    feedbackform = FeedbackForm()
    user = None
    given_feedback = []
    if 'email' in session: 
        user = get_user(session['email'])
        if user.role == 'admin':
            # For admins, the feedback is shown
            given_feedback = get_feedback()
    
    if feedbackform.validate_on_submit():
        feedback = Feedback(created = datetime.now(),
                            description=feedbackform.description.data,
                            user=user)
        save_feedback(feedback)
        flash(_(u"Feedback saved. Thank you!"))
        return redirect(url_for('troikas'))
        
    if feedbackform.errors:
        for key, value in feedbackform.errors.items():
            feedbackerrors.append(key + ': ' + value[0])

    return render_template('feedback.html', feedbackform=feedbackform, 
                           feedbackerrors=feedbackerrors,
                           given_feedback=given_feedback)
开发者ID:ttiurani,项目名称:troikalearning,代码行数:26,代码来源:views.py

示例7: feedback

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,代码行数:26,代码来源:views.py

示例8: feedback

def feedback(request):
    if request.method == 'POST' and request.is_ajax():
        f = FeedbackForm(request.POST)
        f.save()
        return HttpResponse()
    else:
        return HttpResponseBadRequest()
开发者ID:prateek-iiitd,项目名称:IIITDAlumniPortal,代码行数:7,代码来源:views.py

示例9: contact

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,代码行数:30,代码来源:views.py

示例10: feedback

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,代码行数:9,代码来源:views.py

示例11: show_feedback_form

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,代码行数:9,代码来源:views.py

示例12: enter

def enter():
#hacky hack
    form = FeedbackForm(csrf_enabled = False)
    if form.validate_on_submit():
        print 'woot!'
        ad = form_to_dict(form)
        handle_form_data(ad)
        return redirect('/')
    return render_template('form.html',form = form)
开发者ID:madhavsuresh,项目名称:premier,代码行数:9,代码来源:views.py

示例13: send_feedback

def send_feedback():
    form = FeedbackForm()
    if form.validate_on_submit():
        newFeedback = Feedback(sender=g.user,text=form.text.data, timestamp=datetime.utcnow())
        db.session.add(newFeedback)
        db.session.commit()
        flash('Your feedback has been submitted! Thank you!')
        return redirect(url_for('index'))
    return render_template('send_feedback.html',
        form = form)
开发者ID:JrtPec,项目名称:coopkot,代码行数:10,代码来源:views.py

示例14: feedback_view

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,代码行数:11,代码来源:views.py

示例15: feedback

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,代码行数:11,代码来源:views.py


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