• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.WorkshopGame类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: workshop_mark4review

def workshop_mark4review(request, workshop):
    workshop = get_object_or_404(Workshop, pk=workshop)

    if workshop.is_started():
        WorkshopGame.start_reviewing(workshop)

    return redirect('ws_workshops')
开发者ID:AndreiRO,项目名称:wouso,代码行数:7,代码来源:cpanel.py


示例2: index

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)
    )
开发者ID:anaion,项目名称:wouso,代码行数:14,代码来源:views.py


示例3: index

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,代码行数:14,代码来源:views.py


示例4: schedule_change

def schedule_change(request, schedule=None):
    class SCForm(forms.ModelForm):
        class Meta:
            model = Schedule
            fields = ('name', 'start_date', 'end_date')

    if schedule:
        schedule = get_object_or_404(Schedule, pk=schedule)

    if request.method == 'POST':
        form = SCForm(request.POST, instance=schedule)
        if form.is_valid():
            sc = form.save()
            sc.category = WorkshopGame.get_question_category()
            sc.save()
            return redirect('ws_schedule')
    else:
        form = SCForm(instance=schedule)

    return render_to_response('workshop/cpanel/schedule_change.html',
                        {'module': 'workshop',
                         'form': form,
                         'instance': schedule},
                        context_instance=RequestContext(request)
    )
开发者ID:alexef,项目名称:wouso-1,代码行数:25,代码来源:cpanel.py


示例5: index

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)
    )
开发者ID:TomyRO,项目名称:wouso,代码行数:16,代码来源:views.py


示例6: play

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,代码行数:32,代码来源:views.py


示例7: play

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)
    )
开发者ID:MathPlayer,项目名称:wouso,代码行数:34,代码来源:views.py


示例8: kick_off

def kick_off(request, player):
    player = get_object_or_404(Player, pk=player)

    sgs = player.playergroup_set.filter(owner=WorkshopGame.get_instance())
    for s in sgs:
        s.players.remove(player)

    return redirect('workshop_home')
开发者ID:AndreiRO,项目名称:wouso,代码行数:8,代码来源:cpanel.py


示例9: schedule

def schedule(request):
    schedules = Schedule.objects.all().order_by('start_date', 'name')

    return render_to_response('workshop/cpanel/schedule.html',
                        {'module': 'workshop',
                         'schedules': schedules,
                         'category': WorkshopGame.get_question_category(),
                         'page': 'schedule'},
                        context_instance=RequestContext(request)
    )
开发者ID:AndreiRO,项目名称:wouso,代码行数:10,代码来源:cpanel.py


示例10: add_group

def add_group(request):
    if request.method == 'POST':
        form = AGForm(request.POST)
        if form.is_valid():
            sg = form.save()
            sg.owner = WorkshopGame.get_instance()
            sg.save()
            return redirect('ws_edit_spot', day=sg.day, hour=sg.hour)
    else:
        form = AGForm()

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


示例11: post

    def post(self, request, *args, **kwargs):
        error = ''
        form = WAForm(request.POST)
        if form.is_valid():
            error = WorkshopGame.create_workshop(semigroup=form.cleaned_data['semigroup'],
                                    date=form.cleaned_data['date'],
                                    title=form.cleaned_data['title'],
                                    question_count=form.cleaned_data['question_count']
            )
            if not error:
                return redirect('ws_workshops')

        return render_to_response('workshop/cpanel/workshop_add.html',
                            {'module': 'workshop', 'form': form, 'info': WorkshopGame, 'error': error,
                             'page': 'workshops'},
                            context_instance=RequestContext(request)
        )
开发者ID:alexukf,项目名称:wouso,代码行数:17,代码来源:cpanel.py


示例12: workshop_add

def workshop_add(request):
    error = ''
    if request.method == 'POST':
        form = WAForm(request.POST)
        if form.is_valid():
            error = WorkshopGame.create_workshop(semigroup=form.cleaned_data['semigroup'],
                                    date=form.cleaned_data['date'],
                                    question_count=form.cleaned_data['question_count']
            )
            if not error:
                return redirect('ws_workshops')
    else:
        form = WAForm()

    return render_to_response('workshop/cpanel/workshop_add.html',
                        {'module': 'workshop', 'form': form, 'info': WorkshopGame, 'error': error},
                        context_instance=RequestContext(request)
    )
开发者ID:anaion,项目名称:wouso,代码行数:18,代码来源:cpanel.py


示例13: edit_group

def edit_group(request, semigroup):
    semigroup = get_object_or_404(Semigroup, pk=semigroup)

    if request.method == 'POST':
        form = AGForm(request.POST, instance=semigroup)
        if form.is_valid():
            sg = form.save()
            sg.owner = WorkshopGame.get_instance()
            sg.save()
            return redirect('ws_edit_spot', day=sg.day, hour=sg.hour)
    else:
        form = AGForm(instance=semigroup)

    return render_to_response('workshop/cpanel/editgroup.html',
            {'module': 'workshop',
             'form': form,
             'instance': semigroup,
             },
        context_instance=RequestContext(request)
    )
开发者ID:alexef,项目名称:wouso-1,代码行数:20,代码来源:cpanel.py


示例14: edit_spot

def edit_spot(request, day, hour):
    day, hour = int(day), int(hour)
    sgs = WorkshopGame.get_by_day_and_hour(day, hour)

    if not sgs:
        return redirect('ws_add_group')

    if request.method == 'POST':
        semigroup = get_object_or_404(Semigroup, pk=request.GET.get('semigroup'))
        try:
            player = Player.objects.get(pk=int(request.POST.get('player')))
        except (ValueError, Player.DoesNotExist):
            pass
        else:
            semigroup.add_player(player)

    return render_to_response(
        'workshop/cpanel/editspot.html',
        {'module': 'workshop', 'semigroups': sgs},
        context_instance=RequestContext(request)
    )
开发者ID:MathPlayer,项目名称:wouso,代码行数:21,代码来源:cpanel.py


示例15: schedule_change

def schedule_change(request, schedule=None):
    if schedule:
        schedule = get_object_or_404(Schedule, pk=schedule)

    if request.method == 'POST':
        form = SCForm(request.POST, instance=schedule)
        if form.is_valid():
            sc = form.save()
            sc.category = WorkshopGame.get_question_category()
            sc.save()
            return redirect('ws_schedule')
    else:
        form = SCForm(instance=schedule)

    return render_to_response('workshop/cpanel/schedule_change.html',
                        {'module': 'workshop',
                         'form': form,
                         'instance': schedule,
                         'page': 'schedule'},
                        context_instance=RequestContext(request)
    )
开发者ID:cvicentiu,项目名称:wouso,代码行数:21,代码来源:cpanel.py


示例16: form_valid

 def form_valid(self, form):
     sg = form.save()
     sg.owner = WorkshopGame.get_instance()
     sg.save()
     return redirect('ws_edit_spot', day=sg.day, hour=sg.hour)
开发者ID:AndreiRO,项目名称:wouso,代码行数:5,代码来源:cpanel.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python Box.Box类代码示例发布时间:2022-05-27
下一篇:
Python models.WikiPage类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap