diff options
author | adityacp | 2020-03-13 17:01:07 +0530 |
---|---|---|
committer | adityacp | 2020-03-13 17:01:07 +0530 |
commit | 369b65aa7a4b9efe5fe8053a1402067e8cedb6e1 (patch) | |
tree | 8d68fd1dba6dd493ffb4313afe8c02be56d6df64 /yaksh | |
parent | fc12aa3d0309d0ac76c29acea52b2bf917605fad (diff) | |
download | online_test-369b65aa7a4b9efe5fe8053a1402067e8cedb6e1.tar.gz online_test-369b65aa7a4b9efe5fe8053a1402067e8cedb6e1.tar.bz2 online_test-369b65aa7a4b9efe5fe8053a1402067e8cedb6e1.zip |
Show success or failure message design course page
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/views.py | 55 |
1 files changed, 39 insertions, 16 deletions
diff --git a/yaksh/views.py b/yaksh/views.py index c0693d7..b7b1524 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -2815,35 +2815,58 @@ def design_course(request, course_id): learning_module.save() to_add_list.append(learning_module) course.learning_module.add(*to_add_list) + messages.success(request, "Modules added successfully") + else: + messages.warning(request, "Please select atleast one module") if "Change" in request.POST: - order_list = request.POST.get("ordered_list").split(",") - for order in order_list: - learning_unit, learning_order = order.split(":") - if learning_order: - learning_module = course.learning_module.get( - id=learning_unit) - learning_module.order = learning_order - learning_module.save() + order_list = request.POST.get("ordered_list") + if order_list: + order_list = order_list.split(",") + for order in order_list: + learning_unit, learning_order = order.split(":") + if learning_order: + learning_module = course.learning_module.get( + id=learning_unit) + learning_module.order = learning_order + learning_module.save() + messages.success(request, "Changed order successfully") + else: + messages.warning(request, "Please select atleast one module") if "Remove" in request.POST: remove_values = request.POST.getlist("delete_list") if remove_values: course.learning_module.remove(*remove_values) + messages.success(request, "Modules removed successfully") + else: + messages.warning(request, "Please select atleast one module") if "change_prerequisite_completion" in request.POST: unit_list = request.POST.getlist("check_prereq") - for unit in unit_list: - learning_module = course.learning_module.get(id=unit) - learning_module.toggle_check_prerequisite() - learning_module.save() + if unit_list: + for unit in unit_list: + learning_module = course.learning_module.get(id=unit) + learning_module.toggle_check_prerequisite() + learning_module.save() + messages.success( + request, "Changed prerequisite check successfully" + ) + else: + messages.warning(request, "Please select atleast one module") if "change_prerequisite_passing" in request.POST: unit_list = request.POST.getlist("check_prereq_passes") - for unit in unit_list: - learning_module = course.learning_module.get(id=unit) - learning_module.toggle_check_prerequisite_passes() - learning_module.save() + if unit_list: + for unit in unit_list: + learning_module = course.learning_module.get(id=unit) + learning_module.toggle_check_prerequisite_passes() + learning_module.save() + messages.success( + request, "Changed prerequisite check successfully" + ) + else: + messages.warning(request, "Please select atleast one module") added_learning_modules = course.get_learning_modules() all_learning_modules = LearningModule.objects.filter( |