Beispiel #1
0
    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)
        )
Beispiel #2
0
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)
    )
Beispiel #3
0
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,
                         'page': 'workshops'},
                        context_instance=RequestContext(request)
    )
Beispiel #4
0
    def post(self, request, *args, **kwargs):
        error = ''
        form = WAForm(request.POST)
        if form.is_valid():
            try:
                workshop = 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'])
            except ValueError as e:
                error = str(e)
            else:
                return redirect('ws_status', pk=workshop.pk)

        return render_to_response('workshop/cpanel/workshop_add.html', {
            'module': 'workshop',
            'form': form,
            'info': WorkshopGame,
            'error': error,
            'page': 'workshops'
        },
                                  context_instance=RequestContext(request))