本文整理汇总了Python中game.models.Game.current_turn方法的典型用法代码示例。如果您正苦于以下问题:Python Game.current_turn方法的具体用法?Python Game.current_turn怎么用?Python Game.current_turn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类game.models.Game
的用法示例。
在下文中一共展示了Game.current_turn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from game.models import Game [as 别名]
# 或者: from game.models.Game import current_turn [as 别名]
def create(request):
if request.method == 'POST':
gf = GameForm(request.POST)
if gf.is_valid():
users = gf.cleaned_data['users']
g = Game()
g.save()
for user in users:
p = Player.objects.create(user=user,
game=g,
points=0)
p = Player.objects.create(user=request.user,
game=g,
points=0)
topics = Topic.objects.filter(deleted=False).order_by('?')
for topic in topics:
game_topic = GameTopic.objects.create(topic=topic,
game=g)
#create turn
turn = Turn.objects.create(game=g,
num=1,
judge=request.user)
g.current_turn = turn
g.save()
return HttpResponseRedirect(reverse('game', kwargs={'game_id':g.id}))
else:
gf = GameForm()
try:
fb_profile = FacebookSession.objects.get(user=request.user)
except FacebookSession.DoesNotExist:
raise Http404
user_friends_list, user_friends_queryset, only_fb_friends_list = get_friends_list(fb_profile)
gf.fields["users"].queryset = user_friends_queryset
template_context = {'gf': gf,
'user_friends_list':user_friends_list,
'fb_friends_list':only_fb_friends_list}
return render_to_response('create_game.html', template_context, context_instance=RequestContext(request))