當前位置: 首頁>>代碼示例>>Python>>正文


Python Game.nearest_game方法代碼示例

本文整理匯總了Python中HVZ.main.models.Game.nearest_game方法的典型用法代碼示例。如果您正苦於以下問題:Python Game.nearest_game方法的具體用法?Python Game.nearest_game怎麽用?Python Game.nearest_game使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在HVZ.main.models.Game的用法示例。


在下文中一共展示了Game.nearest_game方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: save

# 需要導入模塊: from HVZ.main.models import Game [as 別名]
# 或者: from HVZ.main.models.Game import nearest_game [as 別名]
    def save(self, commit=False):
        def grab(s):
            return self.cleaned_data[s]

        game = Game.nearest_game()
        player = Player.user_to_player(self.user, game)

        self.thread = Thread(
            game=game,
            team=grab('team'),
            title=grab('title'),
            slug=slugify(grab('title')),
        )

        self.thread.save()

        post = Post(
            author=player,
            thread=self.thread,
            body=grab('post_body'),
            created=settings.NOW(),
        )

        if commit:
            post.save()

        return self.thread
開發者ID:Mongoose1021,項目名稱:claremontHvZ,代碼行數:29,代碼來源:forms.py

示例2: game

# 需要導入模塊: from HVZ.main.models import Game [as 別名]
# 或者: from HVZ.main.models.Game import nearest_game [as 別名]
    def game(self):
        if self._game:
            return self._game
        try:
            self._game = Game.nearest_game()
        except Game.DoesNotExist:
            raise PermissionDenied("You need to create a game!")

        return self._game
開發者ID:Mongoose1021,項目名稱:claremontHvZ,代碼行數:11,代碼來源:mixins.py

示例3: get_context_data

# 需要導入模塊: from HVZ.main.models import Game [as 別名]
# 或者: from HVZ.main.models.Game import nearest_game [as 別名]
    def get_context_data(self, **kwargs):
        context = super(PlayerListView, self).get_context_data(**kwargs)
        context['game_season'] = Game.nearest_game().season()

        context['schools'] = School.objects.all().annotate(
            num_players=Count('player_set')
        ).order_by('-num_players')

        context['years'] = map(str, sorted(set([p.grad_year for p in Player.current_players()])))
        context['school'] = self.kwargs.get('school', '')
        context['gradyear'] = self.kwargs.get('gradyear', '')

        return context
開發者ID:Mongoose1021,項目名稱:claremontHvZ,代碼行數:15,代碼來源:views.py

示例4: inject_outbreak_percentage

# 需要導入模塊: from HVZ.main.models import Game [as 別名]
# 或者: from HVZ.main.models.Game import nearest_game [as 別名]
def inject_outbreak_percentage(request):
    try:
        newest_game = Game.nearest_game()
    except Game.DoesNotExist:
        # Just return an arbitrary sane value
        return {'outbreak_percent': 96}

    players = Player.objects.filter(game=newest_game)
    humans = players.filter(team='H')

    nPlayers = players.count()

    if nPlayers > 0:
        percent = humans.count() * 100. / nPlayers
    else:
        percent = 100

    return {'outbreak_percent': min(96, percent)}
開發者ID:Mongoose1021,項目名稱:claremontHvZ,代碼行數:20,代碼來源:context_processors.py

示例5: get_queryset

# 需要導入模塊: from HVZ.main.models import Game [as 別名]
# 或者: from HVZ.main.models.Game import nearest_game [as 別名]
 def get_queryset(self):
     return Player.objects.all().filter(game=Game.nearest_game())
開發者ID:JoshPetrack,項目名稱:claremontHvZ,代碼行數:4,代碼來源:views.py

示例6: get_queryset

# 需要導入模塊: from HVZ.main.models import Game [as 別名]
# 或者: from HVZ.main.models.Game import nearest_game [as 別名]
 def get_queryset(self):
     game = Game.nearest_game()
     return Player.objects.filter(game=game)
開發者ID:Mongoose1021,項目名稱:claremontHvZ,代碼行數:5,代碼來源:views.py


注:本文中的HVZ.main.models.Game.nearest_game方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。