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


Python Feedback.put方法代码示例

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


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

示例1: feedback

# 需要导入模块: from models import Feedback [as 别名]
# 或者: from models.Feedback import put [as 别名]
    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,代码行数:28,代码来源:api_controller.py

示例2: post

# 需要导入模块: from models import Feedback [as 别名]
# 或者: from models.Feedback import put [as 别名]
    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,代码行数:29,代码来源:handlers.py

示例3: submit

# 需要导入模块: from models import Feedback [as 别名]
# 或者: from models.Feedback import put [as 别名]
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,代码行数:13,代码来源:views.py

示例4: submit

# 需要导入模块: from models import Feedback [as 别名]
# 或者: from models.Feedback import put [as 别名]
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,代码行数:16,代码来源:views.py

示例5: post

# 需要导入模块: from models import Feedback [as 别名]
# 或者: from models.Feedback import put [as 别名]
 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,代码行数:18,代码来源:main.py

示例6: post

# 需要导入模块: from models import Feedback [as 别名]
# 或者: from models.Feedback import put [as 别名]
 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,代码行数:19,代码来源:main.py

示例7: post

# 需要导入模块: from models import Feedback [as 别名]
# 或者: from models.Feedback import put [as 别名]
 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,代码行数:19,代码来源:handlers.py


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