From 674c81d9e1d3499e255e8995701fb65d1358a0ac Mon Sep 17 00:00:00 2001 From: adityacp Date: Wed, 4 Mar 2020 17:11:20 +0530 Subject: Change settings - Add messages in grading systems page - Add password validator in settings - Fix naming in templates --- grades/views.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'grades/views.py') diff --git a/grades/views.py b/grades/views.py index 7403e4e..48cd8e3 100644 --- a/grades/views.py +++ b/grades/views.py @@ -1,6 +1,7 @@ from django.shortcuts import render from django.contrib.auth.decorators import login_required from django.forms import inlineformset_factory +from django.contrib import messages from grades.forms import GradingSystemForm, GradeRangeForm from grades.models import GradingSystem, GradeRange @@ -30,12 +31,13 @@ def add_grading_system(request, system_id=None): formset = GradeRangeFormSet(request.POST, instance=grading_system) grade_form = GradingSystemForm(request.POST, instance=grading_system) if grade_form.is_valid(): - system = grade_form.save(commit=False) - system.creator = user - system.save() - system_id = system.id - if formset.is_valid(): - formset.save() + grading_system = grade_form.save(commit=False) + grading_system.creator = user + grading_system.save() + system_id = grading_system.id + if formset.is_valid(): + formset.save() + messages.success(request, "Grading system saved successfully") if 'add' in request.POST: GradeRangeFormSet = inlineformset_factory( GradingSystem, GradeRange, GradeRangeForm, extra=1 -- cgit