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


Python models.WorkshopGame類代碼示例

本文整理匯總了Python中models.WorkshopGame的典型用法代碼示例。如果您正苦於以下問題:Python WorkshopGame類的具體用法?Python WorkshopGame怎麽用?Python WorkshopGame使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了WorkshopGame類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


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