Fix: course add and drop

This commit is contained in:
Adil Mohak 2024-10-06 11:03:56 +03:00
parent 53bb419566
commit 6f082c08f7
2 changed files with 9 additions and 17 deletions

View File

@ -472,6 +472,7 @@ def course_drop(request):
if request.method == "POST": if request.method == "POST":
student = get_object_or_404(Student, student__pk=request.user.id) student = get_object_or_404(Student, student__pk=request.user.id)
course_ids = request.POST.getlist("course_ids") course_ids = request.POST.getlist("course_ids")
print("course_ids", course_ids)
for course_id in course_ids: for course_id in course_ids:
course = get_object_or_404(Course, pk=course_id) course = get_object_or_404(Course, pk=course_id)
TakenCourse.objects.filter(student=student, course=course).delete() TakenCourse.objects.filter(student=student, course=course).delete()

View File

@ -182,31 +182,18 @@
{% if not no_course_is_registered %} {% if not no_course_is_registered %}
<a class="btn btn-warning" href="{% url 'course_registration_form' %}" target="_blank" title="{% trans 'Print Registration Form' %}">
<i class="fas fa-print"></i> {% trans 'Print Registerd Courses' %}
</a>
<div class="col-md-12 p-0 bg-white"> <div class="col-md-12 p-0 bg-white">
<p class="form-title"><b>{% trans 'Course Drop' %}</b> <p class="form-title"><b>{% trans 'Course Drop' %}</b></p>
<div class="level-wrapper">
<div class="info-text">{{ student.level }}</div>
</div>
</p>
<div class="container"> <div class="container">
<p class="fw-bold">{{ student.level }}</p>
<form action="{% url 'course_drop' %}" method="POST"> <form action="{% url 'course_drop' %}" method="POST">
{% csrf_token %} {% csrf_token %}
<div class="d-flex justify-content-between mb-4"> <div class="d-flex justify-content-between mb-4">
<button title="{% trans 'Save Score' %}" type="submit" class="btn btn-primary"> <button type="submit" class="btn btn-primary">
<i class="fa fa-times"></i> {% trans 'Drop Selected' %} <i class="fa fa-times"></i> {% trans 'Drop Selected' %}
</button> </button>
</div> </div>
<!-- <div>
<a target="_blank" href="{% url 'course_registration_form' %}" class="btn btn-outline-white btn-rounded btn-sm px-2">
<i class="fa fa-file-pdf-o" aria-hidden="true"></i> Print Registration Form
</a>
</div> -->
<div class="table-responsive p-0 px-2 mt-2"> <div class="table-responsive p-0 px-2 mt-2">
<div class="table-shadow"> <div class="table-shadow">
<table class="table"> <table class="table">
@ -225,7 +212,7 @@
{% for course in registered_courses %} {% for course in registered_courses %}
<tr> <tr>
<th scope="row"> <th scope="row">
<input name="{{ course.pk }}" value="{{ course.courseUnit }}" type="checkbox"> <input name="course_ids" value="{{ course.id }}" type="checkbox">
</th> </th>
<td>{{ course.code }}</td> <td>{{ course.code }}</td>
<td>{{ course.title }}</td> <td>{{ course.title }}</td>
@ -270,6 +257,10 @@
</div> </div>
</div> </div>
<a class="btn btn-sm btn-secondary mt-3" href="{% url 'course_registration_form' %}" target="_blank" title="{% trans 'Print Registration Form' %}">
<i class="fas fa-print"></i> {% trans 'Print Registerd Courses' %}
</a>
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endif %} {% endif %}