diff options
-rw-r--r-- | grades/templates/add_grades.html | 35 | ||||
-rw-r--r-- | grades/templates/grading_systems.html | 2 | ||||
-rw-r--r-- | grades/views.py | 14 | ||||
-rw-r--r-- | online_test/settings.py | 18 | ||||
-rw-r--r-- | yaksh/templates/yaksh/add_course.html | 2 | ||||
-rw-r--r-- | yaksh/templates/yaksh/add_quiz.html | 12 | ||||
-rw-r--r-- | yaksh/templates/yaksh/courses.html | 2 | ||||
-rw-r--r-- | yaksh/templates/yaksh/lessons.html | 2 | ||||
-rw-r--r-- | yaksh/templates/yaksh/modules.html | 2 | ||||
-rw-r--r-- | yaksh/templates/yaksh/quizzes.html | 2 | ||||
-rw-r--r-- | yaksh/views.py | 2 |
11 files changed, 73 insertions, 20 deletions
diff --git a/grades/templates/add_grades.html b/grades/templates/add_grades.html index 59a344d..f53a337 100644 --- a/grades/templates/add_grades.html +++ b/grades/templates/add_grades.html @@ -14,7 +14,7 @@ </li> <li class="nav-item"> <a class="nav-link" href="{% url 'yaksh:add_course' %}"> - Add New Course + Add/Edit Course </a> </li> <li class="nav-item dropdown hide"> @@ -46,13 +46,44 @@ Note: For grade range lower limit is inclusive and upper limit is exclusive </div> <br> +{% if messages %} + {% for message in messages %} + <div class="alert alert-dismissible alert-{{ message.tags }}"> + <button type="button" class="close" data-dismiss="alert"> + <i class="fa fa-close"></i> + </button> + <strong>{{ message }}</strong> + </div> + {% endfor %} + <br> +{% endif %} {% if not system_id %} <form action="{% url 'grades:add_grade' %}" method="POST"> {% else %} <form action="{% url 'grades:edit_grade' system_id %}" method="POST"> {% endif %} {% csrf_token %} - <table class="table"> + <table class="table table-responsive-sm"> + {% if grade_form.errors %} + {% for field in grade_form %} + {% for error in field.errors %} + <div class="alert alert-dismissible alert-danger"> + <button type="button" class="close" data-dismiss="alert"> + <i class="fa fa-close"></i> + </button> + <strong>{{ error|escape }}</strong> + </div> + {% endfor %} + {% endfor %} + {% for error in grade_form.non_field_errors %} + <div class="alert alert-dismissible alert-danger"> + <button type="button" class="close" data-dismiss="alert"> + <i class="fa fa-close"></i> + </button> + <strong>{{ error|escape }}</strong> + </div> + {% endfor %} + {% endif %} {% for field in grade_form %} {{ field }} <hr> diff --git a/grades/templates/grading_systems.html b/grades/templates/grading_systems.html index 8102230..88adfa0 100644 --- a/grades/templates/grading_systems.html +++ b/grades/templates/grading_systems.html @@ -13,7 +13,7 @@ </li> <li class="nav-item"> <a class="nav-link" href="{% url 'yaksh:add_course' %}"> - Add New Course + Add/Edit Course </a> </li> <li class="nav-item dropdown hide"> 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 diff --git a/online_test/settings.py b/online_test/settings.py index 7b0e2d4..66d77c3 100644 --- a/online_test/settings.py +++ b/online_test/settings.py @@ -188,3 +188,21 @@ SOCIAL_AUTH_FACEBOOK_SCOPE = ['email'] SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = { 'fields': 'id, name, email' } + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + 'OPTIONS': { + 'min_length': 8, + } + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] diff --git a/yaksh/templates/yaksh/add_course.html b/yaksh/templates/yaksh/add_course.html index 72403ce..97c6f56 100644 --- a/yaksh/templates/yaksh/add_course.html +++ b/yaksh/templates/yaksh/add_course.html @@ -23,7 +23,7 @@ </li> <li class="nav-item"> <a class="nav-link active" href="{% url 'yaksh:add_course' %}"> - Add New Course + Add/Edit Course </a> </li> <li class="nav-item dropdown hide"> diff --git a/yaksh/templates/yaksh/add_quiz.html b/yaksh/templates/yaksh/add_quiz.html index 57b4d77..5497eeb 100644 --- a/yaksh/templates/yaksh/add_quiz.html +++ b/yaksh/templates/yaksh/add_quiz.html @@ -14,6 +14,12 @@ <script src="{% static 'yaksh/js/jquery-3.3.1.min.js' %}"></script> <script src="{% static 'yaksh/js/add_quiz.js' %}"></script> <script src="{% static 'yaksh/js/jquery.datetimepicker.full.min.js' %}"></script> +<script type="text/javascript"> + $(document).ready(function() { + $("#id_start_date_time").datetimepicker({format: 'Y-m-d H:i:s'}); + $("#id_end_date_time").datetimepicker({format: 'Y-m-d H:i:s'}); + }); +</script> {% endblock %} {% block onload %} onload="javascript:test();" {% endblock %} @@ -44,13 +50,9 @@ <form name=frm id=frm action="" method="post" > {% csrf_token %} <center> - <table class="table"> + <table class="table table-responsive-sm"> {{ form.as_table }} </table> - <script type="text/javascript"> - $("#id_start_date_time").datetimepicker({format: 'Y-m-d H:i:s'}); - $("#id_end_date_time").datetimepicker({format: 'Y-m-d H:i:s'}); - </script> <br/> <button class="btn btn-success btn-lg" id="submit" name="questionpaper"> <i class="fa fa-save"> Save</i> diff --git a/yaksh/templates/yaksh/courses.html b/yaksh/templates/yaksh/courses.html index 0eb9a38..33d44ac 100644 --- a/yaksh/templates/yaksh/courses.html +++ b/yaksh/templates/yaksh/courses.html @@ -29,7 +29,7 @@ </li> <li class="nav-item"> <a class="nav-link" href="{% url 'yaksh:add_course' %}"> - Add New Course + Add/Edit Course </a> </li> <li class="nav-item dropdown hide"> diff --git a/yaksh/templates/yaksh/lessons.html b/yaksh/templates/yaksh/lessons.html index 0146a6b..4b5d18e 100644 --- a/yaksh/templates/yaksh/lessons.html +++ b/yaksh/templates/yaksh/lessons.html @@ -13,7 +13,7 @@ </li> <li class="nav-item"> <a class="nav-link" href="{% url 'yaksh:add_course' %}"> - Add New Course + Add/Edit Course </a> </li> <li class="nav-item dropdown hide"> diff --git a/yaksh/templates/yaksh/modules.html b/yaksh/templates/yaksh/modules.html index 4fafbf1..e835cff 100644 --- a/yaksh/templates/yaksh/modules.html +++ b/yaksh/templates/yaksh/modules.html @@ -14,7 +14,7 @@ </li> <li class="nav-item"> <a class="nav-link" href="{% url 'yaksh:add_course' %}"> - Add New Course + Add/Edit Course </a> </li> <li class="nav-item dropdown hide"> diff --git a/yaksh/templates/yaksh/quizzes.html b/yaksh/templates/yaksh/quizzes.html index 7e53d31..9b40647 100644 --- a/yaksh/templates/yaksh/quizzes.html +++ b/yaksh/templates/yaksh/quizzes.html @@ -14,7 +14,7 @@ </li> <li class="nav-item"> <a class="nav-link" href="{% url 'yaksh:add_course' %}"> - Add New Course + Add/Edit Course </a> </li> <li class="nav-item dropdown hide"> diff --git a/yaksh/views.py b/yaksh/views.py index 3aeaada..23c5a88 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -127,7 +127,7 @@ def user_register(request): Create a user and corresponding profile and store roll_number also.""" user = request.user - if user.is_authenticated(): + if user.is_authenticated: return my_redirect("/exam/quizzes/") context = {} if request.method == "POST": |