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


Python WorkshopGame.get_for_now方法代码示例

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


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

示例1: play

# 需要导入模块: from models import WorkshopGame [as 别名]
# 或者: from models.WorkshopGame import get_for_now [as 别名]
def play(request):
    """
    Play current workshop or show expired message.
    """
    workshop = WorkshopGame.get_for_now()
    player = request.user.get_profile()
    error = ''

    if not workshop:
        return do_error(request, _('No current workshop'))
    elif player not in workshop.semigroup.players.all():
        return do_error(request, _('You are not in the current semigroup'))
    elif not workshop.is_active():
        return do_error(request, _('Workshop is not active'))

    assesment = Assesment.objects.get_or_create(player=player, workshop=workshop)[0]
    if assesment.answered:
        return do_error(request, _('You have already answered this workshop'))

    if request.method == 'POST':
        answers = {}
        for q in workshop.questions.all():
            answers[q.id] = request.POST.get('answer_%d' % q.id)

        assesment.set_answered(answers)
        return redirect('workshop_index_view')

    return render_to_response('workshop/play.html',
                {'assesment': assesment,
                 'workshop': workshop},
                context_instance=RequestContext(request)
    )
开发者ID:alexef,项目名称:wouso-1,代码行数:34,代码来源:views.py

示例2: index

# 需要导入模块: from models import WorkshopGame [as 别名]
# 或者: from models.WorkshopGame import get_for_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)
    )
开发者ID:alexef,项目名称:wouso-1,代码行数:16,代码来源:views.py


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