Пример #1
0
def contest_settings(request, contest_id, contest, tab):
    if request.method == 'POST':
        form = ContestForm(request.POST, instance = contest)
        if form.is_valid():
            contest = form.save()
    else:
        form = ContestForm(instance = contest)
    context = {'subtitles': [contest.name, tab[1][1]], 'contest': contest, 'form': form, 'page': 'contest', 'tabs': tabs}
    return render(request, 'settings/contest.html', context)
Пример #2
0
def add(request):
    if not request.user.is_staff:
        return redirect('scan.views.index')

    if request.method == 'POST':
        form = ContestForm(request.POST)
        if form.is_valid():
            contest = form.save()
            return redirect('scan.views.settings.index', contest_id = contest.id)
    else:
        form = ContestForm()

    context = {'form': form}
    return render(request, 'settings/add.html', context)