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

Python models.Match类代码示例

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

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



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

示例1: match_put

def match_put(mid, pid):
    """ Insert match via Match ID and DotA2 ID """
    if not match_check(mid, pid):
        query = Match(match_id=mid, player=pid)
        query.save()
        return True
    return False
开发者ID:UltimatePancake,项目名称:pqn_dota,代码行数:7,代码来源:factory.py


示例2: test_undo_match

def test_undo_match(g):
    p = Player("test player")
    p2 = Player("test player 2")
    player_dao.create(p)
    p.id = 1
    player_dao.create(p2)
    p2.id = 2
    t = Tournament(0,'','T1','type',0)
    tournament_dao.create(t)
    t.id = 1
    match_dao.create([p.id, p2.id], t.id)
    match_id = 1
    match = Match(player1=p,player2=p2,id=match_id)
    match.score1 = 19
    match.score2 = 21
    match_dao.update(match)

    match_dao.undo(match)
    retrieved_match = match_dao.find(match_id)
    matches = match_dao.find_by_tournament(t.id)

    assert retrieved_match.score1 == 0
    assert retrieved_match.score2 == 0
    assert retrieved_match.player1.fname == p.fname
    assert retrieved_match.player2.fname == p2.fname
    assert retrieved_match.player1.id == p.id
    assert retrieved_match.player2.id == p2.id
    assert not matches[0].entered_time
开发者ID:ewilson,项目名称:tournament,代码行数:28,代码来源:match_dao_test.py


示例3: exists

 def exists(cls,iid,table):
     if table == "match":
         try:
             Match.get(iid=iid)
         except Match.DoesNotExist:
             return False
     if table == "odd":
         try:
             Odd.get(iid=iid)
         except Odd.DoesNotExist:
             return False
     if table == "cat":
         try:
             OddCategory.get(idd=iid)
         except OddCategory.DoesNotExist:
             return False
     if table == "result":
         try:
             Result.get(iid=iid)
         except Result.DoesNotExist:
             return False
     if table == "user":
         try:
             User.get(iid=iid)
         except User.DoesNotExist:
             return False
     return True
开发者ID:Okiria,项目名称:betting,代码行数:27,代码来源:sync.py


示例4: match

def match(request, user_id):
    user = get_object_or_404(Profile, pk=user_id)
    match = Match(date=timezone.now())
    match.save()
    match.users.add(user, request.user)
    match.save()

    return HttpResponseRedirect(reverse('meet:match_detail', args=(match.id,)))
开发者ID:nike508,项目名称:tinder-lang,代码行数:8,代码来源:views.py


示例5: entry

def entry():
    if not session.get('user'):
        return redirect(url_for('index'))

    user = session.get('user')
    u = User.select().where(User.username == user)[0]

    already_entered = Crush.select().where(Crush.user == u)

    if request.method == 'POST':
        entries = filter(None, request.form.getlist("entry"))

        if len(entries) > 5:
            return redirect('entry')

        captcha = request.form.get('g-recaptcha-response')

        captcha_r = requests.post('https://www.google.com/recaptcha/api/siteverify',
                                  data={'secret': '6Lcd-gcTAAAAANlxsT-ptOTxsgRiJKTGTut2VgLk',
                                        'response': captcha,
                                        'remoteip': request.remote_addr})

        if not captcha_r.json()['success']:
            return render_template('entry.html', user=user, entries=entries,
                                    already_entered=already_entered,
                                    already_entered_count=already_entered.count())

        if not any(entries):
            return redirect('entry')

        suggestions = map(lookup, entries)

        for i, entry in enumerate(entries):
            if entry not in suggestions[i]:
                return render_template('entry.html', user=user,
                                                     entries=entries,
                                                     suggestions=suggestions,
                                                     already_entered=already_entered,
                                                     already_entered_count=already_entered.count())

        for entry in entries:
            exists = Crush.select().where(Crush.user == u, Crush.crush == entry).count()
            if not exists:
                Crush.create(user=u, crush=entry)

                crush_user_exists = User.select().where(User.username == entry).count()
                if crush_user_exists:
                    crush_user = User.select().where(User.username == entry)[0]
                    crush_user_crushes = map(lambda m: m.crush, Crush.select().where(Crush.user == crush_user))
                    if crush_user and u.username in crush_user_crushes:
                        Match.create(user_1 = u, user_2 = crush_user)

        return redirect('/matches')

    return render_template('entry.html', user=user,
                            already_entered=already_entered,
                            already_entered_count=already_entered.count())
开发者ID:danasilver,项目名称:lastchances,代码行数:57,代码来源:app.py


示例6: get_all_matches

def get_all_matches(account_id):
    """Try to retrieve and add all matches from a player to the database."""
    matches = api.get_match_history(account_id=account_id)["result"]
    while matches["results_remaining"] >= 0 and matches["num_results"] > 1:
        for match in matches["matches"]:
            try:
                Match.get(Match.match_id == match["match_id"])
            except DoesNotExist:
                new_match_task = add_match.delay(match["match_id"])
        matches = api.get_match_history(account_id=account_id, start_at_match_id=match["match_id"])["result"]
开发者ID:Catgroove,项目名称:dotaninja,代码行数:10,代码来源:tasks.py


示例7: confirm_match

def confirm_match(request, req_id=None):
    if request.method == "POST":
        if req_id is not None:
            try:
                sr = ScoreRequest.objects.get(id=req_id)
            except:
                return HttpResponseRedirect('/welcome/')
            form = ConfirmRequestForm(request.POST, instance=sr)
            print form
            if form.is_valid() and sr.player2.user.username == request.user.username: #and needs to verify player2 is current player lol
                form.save()
                if int(request.POST['verified']) == 2:
                    #Save fields into a Match object now
                    match = Match()
                    match.player1 = sr.player1
                    match.player2 = sr.player2
                    match.wins = sr.wins
                    match.loss = sr.loss
                    match.ties = sr.ties
                    match.tournament = sr.tournament
                    match.save()
                return HttpResponseRedirect('/welcome/') 
            return HttpResponseRedirect('/welcome/')
    else:
        print "Only POST requests for now"
        return HttpResponseRedirect('/welcome/')
开发者ID:edasaur,项目名称:mtg-recorder,代码行数:26,代码来源:views.py


示例8: _trigger_played_match

 def _trigger_played_match(self, match_type):
     if MatchSoloQueue.query(MatchSoloQueue.type == match_type).count() >= 2:
         match_solo_queues = [match_queue for match_queue in MatchSoloQueue.query(MatchSoloQueue.type == match_type).fetch(10)]
         players = [match_queue.player.get() for match_queue in match_solo_queues]
         match = Match(type=match_type)
         match.setup_soloqueue_match(players)
         ndb.delete_multi([queue.key for queue in match_solo_queues])
         for player in players:
             player.doing = match.key
             player.put()
             websocket_notify_player("Player_MatchFound", player.key, None, match.get_data())
开发者ID:Andrioden,项目名称:dotacareer,代码行数:11,代码来源:cron.py


示例9: get

 def get(self):
     #500 is max delete at once limit.
     db.delete(Match.all().fetch(500))
     
     match_count = Match.all().count()
     
     template_values = {
         'match_count': match_count,
     }
     
     path = os.path.join(os.path.dirname(__file__), '../templates/matches/flush.html')
     self.response.out.write(template.render(path, template_values))
开发者ID:Apple101Review,项目名称:the-blue-alliance,代码行数:12,代码来源:datafeed_controller.py


示例10: post

    def post(self):
        player = current_user_player()

        if player.doing:
            error_400(self.response, "ERROR_PLAYER_BUSY", "Player is busy.")
            return

        bot_match = Match(type="Bot")
        bot_match.setup_bot_match(player)

        player.doing = bot_match.key
        player.put()

        set_json_response(self.response, bot_match.get_data("full"))
开发者ID:Andrioden,项目名称:dotacareer,代码行数:14,代码来源:matches.py


示例11: matches

def matches():
    if not session.get('user'):
        return redirect('/login')

    user = User.select().where(User.username == session.get('user'))[0]

    count = Crush.select().where(Crush.crush == session.get('user')).count()

    matches_1 = map(lambda m: m.user_2.username, Match.select().where(Match.user_1 == user))
    matches_2 = map(lambda m: m.user_1.username, Match.select().where(Match.user_2 == user))

    matches_1.extend(matches_2)

    return render_template('match.html', matches=matches_1, count=count, user=user.username)
开发者ID:danasilver,项目名称:lastchances,代码行数:14,代码来源:app.py


示例12: syncMatchTable

 def syncMatchTable(self):
     self.connection.request("GET", "/sync/match")
     response = self.connection.getresponse()
     data = response.read()
     data = json.loads(data)
     print response.read()
     print data
     if not data.has_key('up-to-date'):
         for match in data['name']:
             try:
                 Match.create(iid=match['iid'],homeTeam=match['homeTeam'], awayTeam=match["awayTeam"], startTime=match['startTime'],
                     league=match['league'])
             except Exception, e:
                 print str(e) + "- Match"
开发者ID:Okiria,项目名称:betting,代码行数:14,代码来源:sync.py


示例13: get_matches

def get_matches():
    """
    http://wiki.guildwars2.com/wiki/API:1/wvw/matches
    """
    for m in api.api_request('wvw/matches')['wvw_matches']:
        match = Match(
            match_id=m['wvw_match_id'],
            red=World.objects.get(world_id=m['red_world_id']),
            blue=World.objects.get(world_id=m['blue_world_id']),
            green=World.objects.get(world_id=m['green_world_id']),
            start_time=m['start_time'],
            end_time=m['end_time'])
        match.save()

    return Match.objects.all()
开发者ID:watbe,项目名称:gw2-battle-tools,代码行数:15,代码来源:wvw_requests.py


示例14: check

 def check(self):
     try:
         match = Match.get(iid=self.matchCode.get_text())
         category = OddCategory.get(name=self.category.get_active_text())
         odd = Odd.get(match=match,category=category,oddCode=self.bet.get_text())
         self.addMatchButton.set_sensitive(False)
         self.reason.set_text("Match Started")
     except Match.DoesNotExist:
         self.addMatchButton.set_sensitive(False)
         self.odd.set_text("")
         self.reason.set_text("Invalid Match")
     except OddCategory.DoesNotExist:
         self.addMatchButton.set_sensitive(False)
         self.odd.set_text("")
         self.reason.set_text("Invalid Category")
     except Odd.DoesNotExist:
         self.addMatchButton.set_sensitive(False)
         self.odd.set_text("")
         self.reason.set_text("Invalid Bet")
     else:
         if match.is_valid():
             self.addMatchButton.set_sensitive(True)
             self.reason.set_text("Available")
             self.odd.set_text(str(odd.odd))
         else:
             self.addMatchButton.set_sensitive(False)
             self.reason.set_text("Match Started")
     if len(self.bets)>0 and self.amountstaked.get_text()!= "":
         self.stakebutton.set_sensitive(True)
     else:
         self.stakebutton.set_sensitive(False)
开发者ID:Okiria,项目名称:betting,代码行数:31,代码来源:bet_interface.py


示例15: getCurrentMatchByUser

def getCurrentMatchByUser(current_user_id):
    #Gets the match the user is currently participating in, or None if no match started.
    #TODO: Check & Confirm creation order
    hackathon = Match.all().filter("users =", current_user_id).order("-created").get()
    if not hackathon or (100 in hackathon.outcome): #Most recent is nonexistant or completed
        return None
    return hackathon
开发者ID:dillongrove,项目名称:TheHackers,代码行数:7,代码来源:main.py


示例16: winner

    def winner(self, message):
        # 0: space, 1: winning verb, 2: loser_id, 3: first score, 4: second score
        # then 0 or more of...
        # 5: 2nd game hyphenated score, 6: 2nd game first score, 7: 2nd game second score
        msg = message['text']
        values = re.split(WINNER_REGEX, msg)
        if not values or len(values) < 5:
            return

        loser_id = values[2]

        # csv game list starts after the end of the slack username
        games_csv = msg[(msg.index('>') + 1):]
        games = games_csv.replace(' ', '').split(',')

        for game in games:
            scores = game.split('-')
            if len(scores) != 2:
                continue

            first_score = int(scores[0])
            second_score = int(scores[1])

            try:
                match = Match.create(winner=message['user'], winner_score=first_score, loser=loser_id, loser_score=second_score)
                self.talk('<@' + loser_id + '>: Please type "Confirm ' + str(match.id) + '" to confirm the above match or ignore it if it is incorrect')
            except Exception as e:
                self.talk('Unable to save match. ' + str(e))
开发者ID:mburst,项目名称:slack-elobot,代码行数:28,代码来源:elobot.py


示例17: get

    def get(self):
        """ Send a reminder to players who have unfinished matches """
        app_id = app_identity.get_application_id()

        matches = Match.query(Match.match_over == False)

        players = list()
        for match in matches:
            logger.debug(match)
            players.append(match.player)

        # Remove duplicates in list by list-set-list conversion
        players = list(set(players))

        # Get players from datastore
        players = ndb.get_multi(players)

        # Create message and send to each player
        for player in players:
            subject = 'This is a reminder'
            body = """Hello %s,
                      you have unfinished
                      quizzles business!""" % player.user_name
            mail.send_mail('[email protected]{}.appspotmail.com'.format(app_id),
                           player.email_address,
                           subject,
                           body)
开发者ID:zebralove79,项目名称:fsd_p4g,代码行数:27,代码来源:main.py


示例18: get

 def get(self, name):
     c = Club.get_by_key_name(name)
     if c is None:
         self.response.set_status(404)
         t = JINJA2_ENV.get_template('404.html')
         self.response.out.write(t.render({}))
         return
     cal = CalendarWrap(c.display)
     q = Match.all().filter('home = ', c)
     for match in q:
         cal.add(match)
     q = Match.all().filter('away = ', c)
     for match in q:
         cal.add(match)
     self.response.headers["Content-Type"] = "text/calendar; charset=utf-8"
     self.response.out.write(cal.to_string())
开发者ID:skitazaki,项目名称:jleague-calendar,代码行数:16,代码来源:main.py


示例19: get

    def get(self):
        """Send a reminder email to each User with active Matches.
        Called every hour using a cron job"""
        app_id = app_identity.get_application_id()
        users = User.query(User.email != None)

        for user in users:
            matches = Match.query(ndb.AND(Match.is_active == True,
                                          ndb.OR(
                                              Match.player_1_name == user.name,
                                              Match.player_2_name == user.name)
                                          )).fetch()

            if matches:
                subject = 'Unfinished match reminder!'
                body = 'Hello {}, \n\nThe following matches are still in ' \
                       'progress:\n'.format(user.name)
                html = 'Hello {}, <br><br>The following matches are still in ' \
                       'progress:<br>'.format(user.name)
                for match in matches:
                    body += '{} vs {}\n'.format(match.player_1_name,
                                                match.player_2_name)
                    html += '{} vs {}<br>'.format(match.player_1_name,
                                                  match.player_2_name)
                body += 'https://{}.appspot.com">Continue playing'\
                    .format(app_id)
                html += '<a href="https://{}.appspot.com">Continue playing' \
                        '</a>'.format(app_id)
                mail.send_mail('[email protected]{}.appspotmail.com'.format(app_id),
                               user.email, subject, body, html=html)
开发者ID:boaarmpit,项目名称:udacity_FSND_project4,代码行数:30,代码来源:main.py


示例20: get

 def get(self):
     logging.info( "#1 admin, settings. " )
     
     matches = Match.all()
     
     self.render(u'admin',
                 matches = matches)
开发者ID:phoenix24,项目名称:fb-apps,代码行数:7,代码来源:main.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python models.Member类代码示例发布时间:2022-05-27
下一篇:
Python models.Manifest类代码示例发布时间: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