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


Python models.Feedback类代码示例

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


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

示例1: feedback

    def feedback(self):
        """Provide a feedback for a status.

        Overrides the older feedback if there was any.
        """
        req = json.loads(self.request.body)
        try:
            qid = int(req.get('qid', ''))
            sid = int(req.get('sid', ''))
            score = int(req.get('score', ''))
            if score < -1 or score > 1:
                self.abort(400, detail='Invalid score.')
            uid = self.user_session['user_id']
            q = Query.get_by_id(qid)
            if q is None:
                raise ValueError()
            f = Feedback.gql('WHERE uid = :1 AND qid = :2 AND sid = :3',
                             uid, qid, sid).get()
            if f is None:
                f = Feedback(uid=uid, qid=qid, sid=sid)
            f.score = score
            f.put()
            self.write({'message': 'success'})
        except ValueError:
            self.abort(400,
                       detail='Please specify valid query ID and status ID.')
开发者ID:Bekt,项目名称:tweetement,代码行数:26,代码来源:api_controller.py

示例2: feedback

def feedback(request):
    _user = request.user
    notes = request.POST.get("notes", None)
    if not notes:
        return Jsonify({"status":False, "error":1101, "error_message":"信息不足, 请重新输入。"})
    fdback = Feedback(notes=notes, user_id=_user['uid'], state=0)
    fdback.save()
    return Jsonify({"status":True, "feedback":model_to_dict(fdback), "error":"", "error_message":""})
开发者ID:nick6918,项目名称:ThingCloud,代码行数:8,代码来源:views.py

示例3: post

 def post(self, request):
     form = self.form
     if form.is_valid():
         feedback = Feedback(message=form.cleaned_data["message"][:2000])
         feedback.save()
         return render_to_response("feedback_thanks.html", locals(), context_instance=RequestContext(request))
     else:
         return HttpResponseBadRequest("Invalid form")
开发者ID:amymok,项目名称:college-costs,代码行数:8,代码来源:views.py

示例4: feedback

def feedback():
    feed = request.form['feedback']
    user = request.form['user']
    field = request.form['field']

    senti = sentiment(feed)

    u = Feedback(user=user, feed=feed, field=field, rating=senti)
    u.save()

    return json.dumps([{'status': 'done'}])
开发者ID:Greplr,项目名称:greplr_api_server,代码行数:11,代码来源:views.py

示例5: submit

def submit(request, page, message):
    """
    Save a new feedback message in the database.
    """
    submitter = request.user
    if submitter.is_anonymous():
        submitter = None
    feedback = Feedback(page=page, message=message, submitter=submitter,
                        ip=request.META.get('REMOTE_ADDR', '0.0.0.0'))
    feedback.put()
    return HttpResponseRedirect(page)
开发者ID:jcrocholl,项目名称:minderbot,代码行数:11,代码来源:views.py

示例6: feedback

def feedback(request, result_id):
    try:
        rate_text = request.POST['rate-text']
        rate_score = request.POST['score']
        result = Result.objects.get(pk=result_id)
        feedback = Feedback(rating=rate_score, text=rate_text, result=result)
        feedback.save()
    # TODO arikg: handle smaller exception
    except Exception:
        return redirect('/result/%s/' % result_id, {
            'error_message': "Please fill in the rating and text",
        })
    return redirect('/thanks')
开发者ID:arikg,项目名称:rtlmesite,代码行数:13,代码来源:views.py

示例7: contact

def contact(request):
    if request.method == 'POST':
        c={}
        form = ContactForm(request.POST)
        if form.is_valid():
            feedback = Feedback()
            try:
                feedback.name = form.cleaned_data["con_name"]
                feedback.email = form.cleaned_data["con_emailid"]
                try:
                    feedback.mobile = str(form.cleaned_data["con_mobile"])
                except:
                    feedback.mobile = ""
                #if feedback.mobile is None:
                #    feedback.mobile = 0
                feedback.value = form.cleaned_data["con_text"]
                feedback.save()
                c.update({"success":True})
            except:
                print sys.exc_info()[1]
                return HttpResponse('Error in sending feedback'+str(vars(feedback))+str(sys.exc_info()[0]))
            
            c.update(csrf(request))
            return render_to_response('contact.html',c)
        else:
            c={}
            c.update({"form":form})
            c.update(csrf(request))
            return render_to_response('contact.html',c)
    c={}
    c.update(csrf(request))
    return render_to_response('contact.html',c)
开发者ID:knowngate,项目名称:bloodbank-project,代码行数:32,代码来源:views.py

示例8: post

 def post(self, request):
     form = self.form
     if form.is_valid():
         base_template = BASE_TEMPLATE
         feedback = Feedback(
             message=form.cleaned_data['message'][:2000],
             url=form.cleaned_data['referrer'])
         feedback.save()
         return render_to_response(
             "feedback_thanks.html",
             locals(),
             context_instance=RequestContext(request))
     else:
         return HttpResponseBadRequest("Invalid form")
开发者ID:higs4281,项目名称:college-costs,代码行数:14,代码来源:views.py

示例9: submit

def submit(request, page, message):
    """
    Save a new feedback message in the database.
    """
    # submitter = request.user
    # if submitter.is_anonymous():
    submitter = None
    feedback = Feedback(page=page, message=message, submitter=submitter,
                        ip=request.META.get('REMOTE_ADDR', '0.0.0.0'))
    feedback.put()
    if page == '/':
        page = '/feedback/'
    page += '?feedback=%d' % feedback.key().id()
    return HttpResponseRedirect(page)
开发者ID:dragonslice,项目名称:nxdom,代码行数:14,代码来源:views.py

示例10: vote

def vote(request, id):
    """
    Add a vote for a feedback message, but not twice from the same IP.
    """
    referer = request.META.get('HTTP_REFERER', '/feedback/')
    redirect = HttpResponseRedirect(referer)
    # Check if the selected feedback exists.
    feedback = Feedback.get_by_id(int(id))
    if feedback is None:
        logging.debug("Feedback '%s' not found." % id)
        return redirect
    # Check if this feedback was posted from the same IP.
    ip = request.META.get('REMOTE_ADDR', '0.0.0.0')
    if feedback.ip == ip:
        logging.debug("Feedback '%s' was posted from the same IP." % id)
        return redirect
    # Check if this IP has already voted for this feedback.
    already = Vote.all().filter('feedback', feedback).filter('ip', ip).count()
    if already:
        logging.debug("Feedback '%s' was already voted %d times from this IP."
                      % (id, already))
        return redirect
    # Register this vote to prevent double voting.
    vote = Vote(feedback=feedback, ip=ip)
    vote.put()
    # Increase the points for this feedback.
    feedback.points += 1
    feedback.put()
    return redirect
开发者ID:jcrocholl,项目名称:minderbot,代码行数:29,代码来源:views.py

示例11: post

 def post(self, id):
     user = users.get_current_user()
     event = Event.get_by_id(int(id))
     try:
         if self.request.get('rating'):
             feedback = Feedback(
                 event = event,
                 rating = int(self.request.get('rating')),
                 comment = cgi.escape(self.request.get('comment')))
             feedback.put()
             self.redirect('/event/%s-%s' % (event.key().id(), slugify(event.name)))
         else:
             raise ValueError('Please select a rating')
     except Exception:
         set_cookie(self.response.headers, 'formvalues', dict(self.request.POST))
         self.redirect('/feedback/new/' + id)
开发者ID:jonhull,项目名称:hd-events,代码行数:16,代码来源:main.py

示例12: post

 def post(self, id):
     user = users.get_current_user()
     event = Event.get_by_id(int(id))
     try:
         if self.request.get("rating"):
             feedback = Feedback(
                 event=event, rating=int(self.request.get("rating")), comment=cgi.escape(self.request.get("comment"))
             )
             feedback.put()
             log = HDLog(event=event, description="Posted feedback")
             log.put()
             self.redirect("/event/%s-%s" % (event.key().id(), slugify(event.name)))
         else:
             raise ValueError("Please select a rating")
     except Exception:
         set_cookie(self.response.headers, "formvalues", dict(self.request.POST))
         self.redirect("/feedback/new/" + id)
开发者ID:billsaysthis,项目名称:hd-events,代码行数:17,代码来源:main.py

示例13: post

    def post(self):
        from recaptcha.client import captcha
        captcha_challenge_field = self.get_argument('recaptcha_challenge_field')
        captcha_response_field = self.get_argument('recaptcha_response_field')
        captcha_response = captcha.submit(
            captcha_challenge_field,
            captcha_response_field,
            configuration.RECAPTCHA_PRIVATE_KEY,
            self.request.remote_ip
        )
        if captcha_response.is_valid:
            full_name = self.get_argument('name')
            email = self.get_argument('email')
            subject = self.get_argument('subject')
            content = self.get_argument('content')

            feedback = Feedback()
            feedback.full_name = full_name
            feedback.email = email
            feedback.subject = subject
            feedback.content = content
            feedback.put()

            self.redirect('/')
        else:
            error = captcha_response.error_code
            self.redirect('/contact/feedback?captcha_error=%s' % error)
开发者ID:yesudeep,项目名称:greatshipgroup,代码行数:27,代码来源:handlers.py

示例14: feedback

def feedback(request):
    
    if request.method == 'POST':
        form = FeedbackForm(request.POST)
        if form.is_valid():
            data = Feedback(name=form.cleaned_data['name'], email=form.cleaned_data['email'], comment=form.cleaned_data['comment'])
            data.save()
            message = "Thanks for the feedback"
            context = {'form':FeedbackForm(), 'message':message, 'count':request.session.get('count',0)}
            return render(request, 'feedback/feedback.html', context)
        else:
            # If data is not valid, reload page with error
            message = "Oops! Something went wrong!"
            context = {'form':FeedbackForm(), 'message':message, 'count':request.session.get('count',0)}
            return render(request, 'feedback/feedback.html', context)
    else:
        context = {'form':FeedbackForm(), 'count':request.session.get('count',0)}
        return render(request, 'feedback/feedback.html', context)
开发者ID:glynnbailey,项目名称:myshop,代码行数:18,代码来源:views.py

示例15: get_already_voted

def get_already_voted(request):
    """
    Don't show vote buttons if posted or voted from the same IP.
    """
    ip = request.META.get('REMOTE_ADDR', '0.0.0.0')
    posted = [feedback.id()
              for feedback in Feedback.all(keys_only=True).filter('ip', ip)]
    voted = [vote.feedback_id()
             for vote in Vote.all().filter('ip', ip)]
    # logging.debug('posted=%s voted=%s' % (posted, voted))
    return set(posted + voted)
开发者ID:jcrocholl,项目名称:minderbot,代码行数:11,代码来源:views.py


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