• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Feedback类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: 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


示例17: add

def add(request):
    """Gather feedback for a page, and if it is ok show a thanks message and link back to the page."""

    submit_was_success = False
    return_to_url      = None

    # If it is a post request try to create the feedback
    if request.method == 'POST':
        form = FeedbackForm( request.POST )
        if form.is_valid():
            feedback = Feedback()
            feedback.url      = form.cleaned_data['url']
            feedback.email    = form.cleaned_data['email']
            feedback.comment  = form.cleaned_data['comment']

            # if there is any content in the honeypot field then label this comment as spammy
            if form.cleaned_data['website']:
                feedback.status = 'spammy'
            
            # if the comment starts with an html tag it is probably spam
            if re.search('\A\s*<\w+>', form.cleaned_data['comment']):
                feedback.status = 'spammy'

            if request.user.is_authenticated():
                feedback.user = request.user

            feedback.save()

            submit_was_success = True
            return_to_url = feedback.url or None
        
    else:
        # use GET to grab the url if set
        form = FeedbackForm(initial=request.GET)
        
    
    return render_to_response(
        'feedback/add.html',
        {
            'form':               form,
            'submit_was_success': submit_was_success,
            'return_to_url':      return_to_url,
        },
        context_instance=RequestContext(request)
    )
开发者ID:Code4SA,项目名称:pombola,代码行数:45,代码来源:views.py


示例18: applicant_profile

def applicant_profile(request, event_name, name):
  try:
    applicant = Applicant.objects.get(norm_name=normalize_name(name), event__name=event_name)
  except Applicant.DoesNotExist:
    raise Http404('Applicant does not exist.')
  try:
    event = Event.objects.get(name=event_name)
  except Event.DoesNotExist:
    raise Http404('Event does not exist')
  try:
    feedback = Feedback.objects.get(applicant=applicant, scholar=request.user.mcuser)
  except Feedback.DoesNotExist:
    feedback = Feedback()
    feedback.applicant = applicant
    feedback.scholar = request.user.mcuser
  if request.method == 'POST':
    form = FeedbackForm(request.POST, instance=feedback)
    if (form.is_valid()):
      form.save()
      if request.is_ajax():
        return JsonResponse({'msg': 'saved successfully'})
      return redirect('feedback:index', event_name)
  else:
    form = FeedbackForm(instance=feedback)
  all_feedback = Feedback.objects.filter(applicant=applicant)
  is_interviewer = request.user.mcuser in event.interviewers.all()
  is_assigned = Assignment.objects.filter(scholar=request.user.mcuser, applicant=applicant).exists()

  context = {
      'feedback': all_feedback,
      'applicant': applicant,
      'form': form,
      'state': get_state(),
      'event_name': event_name,
      'survey_link': event.survey_link,
      'is_interviewer': is_interviewer and is_assigned,
      'favorited': favorited(request.user.mcuser, applicant)
      }
  return render(request, 'feedback/applicant.html', context)
开发者ID:mcdermott-scholars,项目名称:mcdermott,代码行数:39,代码来源:views.py


示例19: post

 def post(self):
     full_name = self.get_argument('full_name')
     email = self.get_argument('email')
     phone_number = self.get_argument('phone_number')
     subject = self.get_argument('subject')
     comment = self.get_argument('comment')
     
     from models import Feedback
     feedback = Feedback()
     feedback.full_name = full_name
     feedback.email = email
     feedback.phone_number = phone_number
     feedback.subject = subject
     feedback.comment = comment
     feedback.put()
     
     self.redirect("/")
开发者ID:aswadrangnekar,项目名称:khandelwal,代码行数:17,代码来源:handlers.py


示例20: delete

def delete(request, id):
    """
    Delete a feedback message if the current user is staff, or it was
    posted from the same IP.
    """
    referer = request.META.get('HTTP_REFERER', '/feedback/')
    redirect = HttpResponseRedirect(referer)
    feedback = Feedback.get_by_id(int(id))
    if feedback is None:
        logging.debug("Feedback '%s' not found." % id)
        return redirect
    if feedback.ip == request.META.get('REMOTE_ADDR', '0.0.0.0'):
        logging.debug("Feedback '%s' deleted by same IP." % id)
        feedback.delete()
    elif request.user.is_staff:
        logging.debug("Feedback '%s' deleted by staff member." % id)
        feedback.delete()
    return redirect
开发者ID:jcrocholl,项目名称:minderbot,代码行数:18,代码来源:views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.File类代码示例发布时间:2022-05-27
下一篇:
Python models.Feed类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap