Example #1
0
def create_sheet(request):
    form = SheetForm(request.POST or None)
    if form.is_valid():
        sheet = form.save()
        sheet.save()
        assign_perm('sheets.view_sheet', request.user, sheet)
        assign_perm('sheets.change_sheet', request.user, sheet)
        return redirect('sheets_view')
    return render(request, 'create_sheet.html', {
        'form': form
    })
Example #2
0
def sheet_settings(request, slug):
    sheet = get_object_or_404(Sheet, slug=slug)
    form = SheetForm(request.POST or None, instance=sheet)

    if form.is_valid():
        old_mark_system = sheet.overall_mark_system
        updated_sheet = form.save()
        if updated_sheet.overall_mark_system != old_mark_system and \
                        updated_sheet.overall_mark_system == Sheet.REGEX_SYSTEM:
            return redirect('regex_rules', slug=updated_sheet.slug)
        return redirect('sheet_detail', slug=updated_sheet.slug)

    return render(request, 'sheet_settings.html', {
        'form': form,
        'sheet': sheet
    })