本文整理汇总了Python中models.WorkshopGame.get_for_player_now方法的典型用法代码示例。如果您正苦于以下问题:Python WorkshopGame.get_for_player_now方法的具体用法?Python WorkshopGame.get_for_player_now怎么用?Python WorkshopGame.get_for_player_now使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.WorkshopGame
的用法示例。
在下文中一共展示了WorkshopGame.get_for_player_now方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: index
# 需要导入模块: from models import WorkshopGame [as 别名]
# 或者: from models.WorkshopGame import get_for_player_now [as 别名]
def index(request, extra_context=None):
player = request.user.get_profile()
assessment = WorkshopGame.get_for_player_now(player)
if not extra_context:
extra_context = {}
extra_context.update({'workshopgame': WorkshopGame, 'workshop': WorkshopGame.get_for_player_now(player),
'assessment': assessment, 'semigroup': Semigroup.get_by_player(player)})
return render_to_response('workshop/index.html',
extra_context,
context_instance=RequestContext(request)
)
示例2: play
# 需要导入模块: from models import WorkshopGame [as 别名]
# 或者: from models.WorkshopGame import get_for_player_now [as 别名]
def play(request):
"""
Play current workshop or show expired message.
"""
player = request.user.get_profile()
workshop = WorkshopGame.get_for_player_now(player=player)
if not workshop:
return do_error(request, _('No workshop for you'))
if not workshop.is_active():
return do_error(request, _('Workshop is not active'))
assessment = workshop.get_or_create_assessment(player=player)
if assessment.answered:
return do_error(request, _('You have already answered this workshop'))
if request.method == 'POST':
answers = {}
for q in assessment.questions.all():
answers[q.id] = request.POST.get('answer_%d' % q.id)
assessment.set_answered(answers)
return redirect('workshop_results', workshop=workshop.id)
seconds_left = assessment.time_left()
return render_to_response(
'workshop/play.html',
{'assessment': assessment,
'workshop': workshop,
'seconds_left': seconds_left},
context_instance=RequestContext(request)
)
示例3: index
# 需要导入模块: from models import WorkshopGame [as 别名]
# 或者: from models.WorkshopGame import get_for_player_now [as 别名]
def index(request, extra_context=None):
player = request.user.get_profile()
workshop = WorkshopGame.get_for_player_now(player)
assessment = workshop.get_or_create_assessment(player) if workshop else None
if not extra_context:
extra_context = {}
extra_context.update({'workshopgame': WorkshopGame, 'workshop': WorkshopGame.get_for_player_now(player),
'assessment': assessment, 'semigroup': Semigroup.get_by_player(player),
'history': player.assessments.all().order_by('-workshop__active_until')})
return render_to_response('workshop/index.html',
extra_context,
context_instance=RequestContext(request)
)
示例4: index
# 需要导入模块: from models import WorkshopGame [as 别名]
# 或者: from models.WorkshopGame import get_for_player_now [as 别名]
def index(request, extra_context=None):
player = request.user.get_profile()
assesment = Assesment.get_for_player_and_workshop(request.user.get_profile(), WorkshopGame.get_for_now())
if not extra_context:
extra_context = {}
extra_context.update({'workshopgame': WorkshopGame, 'workshop': WorkshopGame.get_for_player_now(player),
'assesment': assesment})
return render_to_response('workshop/index.html',
extra_context,
context_instance=RequestContext(request)
)