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


Python Game.active_or_latest方法代码示例

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


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

示例1: game_boards

# 需要导入模块: from july.game.models import Game [as 别名]
# 或者: from july.game.models.Game import active_or_latest [as 别名]
 def game_boards(self):
     from july.game.models import Game
     latest = Game.active_or_latest()
     kwargs = {
         'player__user__in': self.members_by_points()
     }
     return latest.board_set.filter(**kwargs).order_by('-points')
开发者ID:cp16net,项目名称:julython.org,代码行数:9,代码来源:models.py

示例2: total_points

# 需要导入模块: from july.game.models import Game [as 别名]
# 或者: from july.game.models.Game import active_or_latest [as 别名]
 def total_points(self):
     from july.game.models import Game, Player
     latest = Game.active_or_latest()
     query = Player.objects.filter(user__team=self, game=latest)
     total = query.aggregate(Sum('points'))
     points = total.get('points__sum')
     return points or 0
开发者ID:ChrisOelmueller,项目名称:julython.org,代码行数:9,代码来源:models.py

示例3: members_by_points

# 需要导入模块: from july.game.models import Game [as 别名]
# 或者: from july.game.models.Game import active_or_latest [as 别名]
 def members_by_points(self):
     from july.game.models import Game
     latest = Game.active_or_latest()
     kwargs = {
         self.rel_lookup: self
     }
     return latest.player_set.filter(**kwargs).order_by('-points')
开发者ID:cp16net,项目名称:julython.org,代码行数:9,代码来源:models.py

示例4: total_points

# 需要导入模块: from july.game.models import Game [as 别名]
# 或者: from july.game.models.Game import active_or_latest [as 别名]
 def total_points(self):
     from july.game.models import Game, Player
     latest = Game.active_or_latest()
     kwargs = {
         self.rel_lookup: self,
         'game': latest
     }
     query = Player.objects.filter(**kwargs)
     total = query.aggregate(Sum('points'))
     points = total.get('points__sum')
     return points or 0
开发者ID:cp16net,项目名称:julython.org,代码行数:13,代码来源:models.py

示例5: live

# 需要导入模块: from july.game.models import Game [as 别名]
# 或者: from july.game.models.Game import active_or_latest [as 别名]
def live(request):
    """Render the live view."""
    game = Game.active_or_latest()

    ctx = Context({
        'game': game,
        'user': request.user,
        'MEDIA_URL': settings.MEDIA_URL,
        'STATIC_URL': settings.STATIC_URL})

    return render_to_response('live/index.html', context_instance=ctx)
开发者ID:julython,项目名称:julython.org,代码行数:13,代码来源:views.py

示例6: get_game

# 需要导入模块: from july.game.models import Game [as 别名]
# 或者: from july.game.models.Game import active_or_latest [as 别名]
 def get_game(self):
     year = int(self.kwargs.get('year', 0))
     mon = int(self.kwargs.get('month', 0))
     day = self.kwargs.get('day')
     if day is None:
         day = 15
     day = int(day)
     if not all([year, mon]):
         now = None
     else:
         now = datetime.datetime(year=year, month=mon, day=day, tzinfo=UTC)
         logging.debug("Getting game for date: %s", now)
     return Game.active_or_latest(now=now)
开发者ID:Parbhat,项目名称:julython.org,代码行数:15,代码来源:views.py

示例7: index

# 需要导入模块: from july.game.models import Game [as 别名]
# 或者: from july.game.models.Game import active_or_latest [as 别名]
def index(request):
    """Render the home page"""
    game = Game.active_or_latest()
    stats = game.histogram

    ctx = Context({
        'stats': json.dumps(stats),
        'game': game,
        'total': sum(stats),
        'user': request.user,
        'MEDIA_URL': settings.MEDIA_URL,
        'STATIC_URL': settings.STATIC_URL})

    return render_to_response('index.html', context_instance=ctx)
开发者ID:kkszysiu,项目名称:julython.org,代码行数:16,代码来源:views.py

示例8: run_query

# 需要导入模块: from july.game.models import Game [as 别名]
# 或者: from july.game.models.Game import active_or_latest [as 别名]
 def run_query(self):
     if self.game is None:
         self.game = Game.active_or_latest()
     # Commit.calender returns a list of objects for each day a user has
     # commited along with the count during the day. So we can use this
     # query to get the total and the number of days.
     resp = Commit.calendar(self.game, user=self.user)
     objects = resp['objects']
     total = 0
     for obj in objects:
         total += obj.get('commit_count', 0)
     return {
         'game_commits': total,
         'game_days': len(objects)
     }
开发者ID:Parbhat,项目名称:julython.org,代码行数:17,代码来源:badges.py

示例9: index

# 需要导入模块: from july.game.models import Game [as 别名]
# 或者: from july.game.models.Game import active_or_latest [as 别名]
def index(request):
    """Render the home page"""
    game = Game.active_or_latest()
    stats = game.histogram if game else []
    posts = Blog.objects.filter(active=True).order_by('-posted')
    try:
        blog = posts[0]
    except:
        blog = None

    ctx = Context({
        'stats': json.dumps(stats),
        'game': game,
        'total': sum(stats),
        'user': request.user,
        'blog': blog,
        'MEDIA_URL': settings.MEDIA_URL,
        'STATIC_URL': settings.STATIC_URL})

    return render_to_response('index.html', context_instance=ctx)
开发者ID:julython,项目名称:julython.org,代码行数:22,代码来源:views.py

示例10: test_active_or_latest_past

# 需要导入模块: from july.game.models import Game [as 别名]
# 或者: from july.game.models.Game import active_or_latest [as 别名]
 def test_active_or_latest_past(self):
     game = self.make_game(start=self.early, end=self.yesterday)
     active = Game.active_or_latest()
     self.assertEqual(active, game)
开发者ID:krotkiewicz,项目名称:julython.org,代码行数:6,代码来源:tests.py

示例11: test_active_or_latest_future

# 需要导入模块: from july.game.models import Game [as 别名]
# 或者: from july.game.models.Game import active_or_latest [as 别名]
 def test_active_or_latest_future(self):
     self.make_game(start=self.tomorrow, end=self.late)
     active = Game.active_or_latest()
     self.assertEqual(active, None)
开发者ID:krotkiewicz,项目名称:julython.org,代码行数:6,代码来源:tests.py

示例12: test_active_or_latest

# 需要导入模块: from july.game.models import Game [as 别名]
# 或者: from july.game.models.Game import active_or_latest [as 别名]
 def test_active_or_latest(self):
     game = self.make_game()
     active = Game.active_or_latest()
     self.assertEqual(active, game)
开发者ID:krotkiewicz,项目名称:julython.org,代码行数:6,代码来源:tests.py

示例13: members_by_points

# 需要导入模块: from july.game.models import Game [as 别名]
# 或者: from july.game.models.Game import active_or_latest [as 别名]
 def members_by_points(self):
     from july.game.models import Game
     latest = Game.active_or_latest()
     return latest.players.filter(team=self).order_by('-player__points')
开发者ID:ChrisOelmueller,项目名称:julython.org,代码行数:6,代码来源:models.py


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