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


Python Transaction.query方法代码示例

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


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

示例1: get_game_history

# 需要导入模块: from models import Transaction [as 别名]
# 或者: from models.Transaction import query [as 别名]
 def get_game_history(self, request):
     """Returns the a listing of all guesses made in the given game"""
     game = get_by_urlsafe(request.urlsafe_game_key, Game)
     tx = Transaction.query(Transaction.game == game.key)
     tx = tx.order(Transaction.date)
     return TransactionForms(transactions=[trans.to_form()
                             for trans in tx])
开发者ID:alfreda99,项目名称:fullstack_designAGame,代码行数:9,代码来源:api.py

示例2: parser_code

# 需要导入模块: from models import Transaction [as 别名]
# 或者: from models.Transaction import query [as 别名]
def parser_code():
    while True:
        code_id = ''.join(random.choice(string.digits) for x in range(6))
        trans = Transaction.query(Transaction.parser_code == code_id).fetch(100)
        if not trans:
            break

    return code_id
开发者ID:H-Freelance-H,项目名称:Media-Pop,代码行数:10,代码来源:functions.py

示例3: get

# 需要导入模块: from models import Transaction [as 别名]
# 或者: from models.Transaction import query [as 别名]
    def get(self):
        if self.user.status == "user":
            self.tv["current_page"] = "DASHBOARD"
            self.render('frontend/dashboard.html')
        elif self.user.status == "admin":
            self.tv["current_page"] = "ADMIN DASHBOARD"

            trans = Transaction.query().order(-Transaction.created).fetch(100)

            self.tv["transactions"] = trans

            self.render('frontend/dashboard-admin.html')
开发者ID:,项目名称:,代码行数:14,代码来源:

示例4: get

# 需要导入模块: from models import Transaction [as 别名]
# 或者: from models.Transaction import query [as 别名]
  def get(self, transaction_ref):
    viewer = self.user_model

    notifications = NotifiedMessage.query(NotifiedMessage.person_reference == viewer.username).fetch(10)
    notis_count = len(notifications)
    msg_count = viewer.msg_count

    qry = Transaction.query(Transaction.transaction_id == transaction_ref).get() #that post
    if qry:
      print "yes"

    if viewer.username in qry.testPeoplewhocanseethis:
      self.response.out.write(template.render('views/transactionDetail.html',{'Onetransaction' : qry,
                                                                              'notifications': notifications,
                                                                              'notis_count': notis_count,
                                                                              'msg_count': msg_count
                                                                              }))
    else:
      self.response.out.write(template.render('views/404notfound.html',{})) #prevent people other than tutor and tutee to see this transaction
开发者ID:nikko0327,项目名称:Ninja-Tutor,代码行数:21,代码来源:Payment.py

示例5: post

# 需要导入模块: from models import Transaction [as 别名]
# 或者: from models.Transaction import query [as 别名]
    def post(self):
        server_base_url = SECRET_SETTINGS["server_base_url"]
        datas = {}
        if self.request.get("code"):
            hashCode = hash_code(self.request.get("code"), "RECEIVER")
            logging.critical(hashCode)

            trans = Transaction.query(Transaction.receiver_code == hashCode).fetch(1)


            if trans:
                if trans[0].status == "received":
                    datas["status"] = "ok"
                    datas["error_code"] = "202"
                    datas["message"] = "This transaction is does not exist!."
                    self.response.out.write(simplejson.dumps(datas))
                    return

                url = server_base_url + "/open/0"
                req = urllib2.Request(url)
                response = urllib2.urlopen(req)
                
                """ change transaction status to DELIVERED """
                trans[0].status = "received"
                trans[0].put()
                """ -------------------------------------- """

                """ send email to the sender """
                sender = ndb.Key(urlsafe=trans[0].sender).get()
                send_email_to_sender(sender.to_object(), trans[0].to_object())
                """ -------------------------------------- """

                datas["status"] = "ok"
                datas["error_code"] = "200"
                datas["message"] = "Package is now claimed! Thanks for using zbox"
                self.response.out.write(simplejson.dumps(datas))
                return
            else:
                hashCode = hash_code(self.request.get("code"), "PARSER")
                trans = Transaction.query(Transaction.parser_code == hashCode).fetch(1)
                datas = {}

                if trans:
                    if trans[0].status == "ready for pickup":
                        datas["status"] = "ok"
                        datas["error_code"] = "202"
                        datas["message"] = "This transaction is now ready for pickup"
                        self.response.out.write(simplejson.dumps(datas))
                        return

                    try:
                        url = server_base_url + "/open/1"
                        req = urllib2.Request(url)
                        response = urllib2.urlopen(req)

                        """ change transaction status to DELIVERED """
                        trans[0].status = "ready for pickup"
                        trans[0].put()
                        """ -------------------------------------- """

                        """ send email to the receiver """
                        receiver = ndb.Key(urlsafe=trans[0].receiver).get()
                        send_email_to_receiver(receiver.to_object(), trans[0].to_object())

                        """ -------------------------------------- """


                        datas["status"] = "ok"
                        datas["error_code"] = "200"
                        datas["message"] = "successsfully delivered"
                        self.response.out.write(simplejson.dumps(datas))
                        return                        
                    except:
                        datas["status"] = "error"
                        datas["error_code"] = "201"
                        datas["message"] = "server is down! you can try again later or contact the administrator!.."
                        self.response.out.write(simplejson.dumps(datas))
                        return
                else:
                    datas["status"] = "error"
                    datas["error_code"] = "201"
                    datas["message"] = "Transaction Does not Exist!.."
                    self.response.out.write(simplejson.dumps(datas))
                    return
开发者ID:,项目名称:,代码行数:86,代码来源:

示例6: get

# 需要导入模块: from models import Transaction [as 别名]
# 或者: from models.Transaction import query [as 别名]
  def get(self, profile_id):
    viewer = self.user_model
    q = User.query(User.username == profile_id)
    user = q.get()
    profile = Profile.query(Profile.owner == user.key).get()
    #if profile isn't created, create one
    if not profile:
      profile = Profile()
      profile.owner = user.key
      profile.about = "I'm new to Techeria. Add me!"
      profile.put()

    TutorPosts = RequestPost.query(RequestPost.requester == profile_id).fetch()
    user.jobpostings = len(TutorPosts)


    # for starring and stuff
    starQry = RequestPost.query(RequestPost.payment_is_done == True)
    tutors_who_can_rate = []
    tutees_who_can_rate = []
    for a in starQry:
      tutors_who_can_rate.append(a.final_provider)
      tutees_who_can_rate.append(a.requester)


    #Get Notifications
    notifications = NotifiedMessage.query(NotifiedMessage.person_reference == viewer.username).fetch(10)
    notis_count = len(notifications)


    trl = Transaction.query()
    transactions_list = []
    for oneTransaction in trl:
      if viewer.username in oneTransaction.testPeoplewhocanseethis:
        transactions_list.append(oneTransaction)


    #Get Emails
    msg_count = viewer.msg_count


    posts_that_are_paid = RequestPost.query(RequestPost.payment_is_done == True).fetch()
    posts_tutors_applied_to = RequestPost.query().fetch()
    #payments history
    #for onePaid in PaidPosts:
      #if onePaid.final_provider == user.username:
      #posts_that_are_paid = PaidPosts


    skill_list = []
    endorsements = Endorsement.query(Endorsement.endorsee == user.key).fetch()
    endorsement_details = EndorsementDetails.query(EndorsementDetails.endorsee == user.key).fetch()
    user.endorsement_count = len(endorsement_details)
    for skill in user.skills:
      skill = skill.get()
      if skill is not None:
        endorsement_list = []
        endorsement_list.append(skill)
        #Get endorsement messages
        #Add number #
        count = 0
        for x in endorsements:
          if x.skill == skill.key:
            count=x.endorsement_count
        endorsement_list.append(count)
        skill_list.append(endorsement_list)

    connection_list = []
    """Get friend count """
    counter = 0
    for connection in user.friends:
      connection = User.get_by_id(connection.id())
      counter+=1
    user.friend_count = counter
    user.put()
    # Get Nested Comments
    comments = Comment.query(Comment.root==True, ndb.OR(Comment.recipient_key == user.key, Comment.sender_key == user.key)).order(-Comment.time).fetch(100)
    index = 0
    while index < len(comments):
      children = Comment.query(Comment.parent == comments[index].key).fetch()
      index += 1
      comments[index:index] = children
    if user:
      self.response.out.write(template.render('views/profile.html',
                                        {'user':user, 
                                        'comments': comments,
                                        'viewer':viewer, 
                                        'skills':skill_list, 
                                        'profile':profile, 
                                        'endorsements':endorsement_details, 
                                        'TutorPosts': TutorPosts, 
                                        'posts_tutors_applied_to': posts_tutors_applied_to, 
                                        'posts_that_are_paid': posts_that_are_paid,
                                        'notifications': notifications,
                                        'notis_count': notis_count,
                                        'transactions_list': transactions_list,
                                        'tutors_who_can_rate': tutors_who_can_rate,
                                        'tutees_who_can_rate': tutees_who_can_rate,
                                        'msg_count': msg_count
                                        }))
开发者ID:nikko0327,项目名称:Ninja-Tutor,代码行数:102,代码来源:main.py


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