Skip to content

Commit

Permalink
Fix: course add and drop
Browse files Browse the repository at this point in the history
  • Loading branch information
adilmohak committed Oct 6, 2024
1 parent 53bb419 commit 6f082c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
1 change: 1 addition & 0 deletions course/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ def course_drop(request):
if request.method == "POST":
student = get_object_or_404(Student, student__pk=request.user.id)
course_ids = request.POST.getlist("course_ids")
print("course_ids", course_ids)
for course_id in course_ids:
course = get_object_or_404(Course, pk=course_id)
TakenCourse.objects.filter(student=student, course=course).delete()
Expand Down
25 changes: 8 additions & 17 deletions templates/course/course_registration.html
Original file line number Diff line number Diff line change
Expand Up @@ -182,31 +182,18 @@ <h5 class="text-light text-center">{% trans 'Check the university calender' %}</

{% 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">
<p class="form-title"><b>{% trans 'Course Drop' %}</b>
<div class="level-wrapper">
<div class="info-text">{{ student.level }}</div>
</div>
</p>
<p class="form-title"><b>{% trans 'Course Drop' %}</b></p>
<div class="container">
<p class="fw-bold">{{ student.level }}</p>
<form action="{% url 'course_drop' %}" method="POST">
{% csrf_token %}
<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' %}
</button>
</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-shadow">
<table class="table">
Expand All @@ -225,7 +212,7 @@ <h5 class="text-light text-center">{% trans 'Check the university calender' %}</
{% for course in registered_courses %}
<tr>
<th scope="row">
<input name="{{ course.pk }}" value="{{ course.courseUnit }}" type="checkbox">
<input name="course_ids" value="{{ course.id }}" type="checkbox">
</th>
<td>{{ course.code }}</td>
<td>{{ course.title }}</td>
Expand Down Expand Up @@ -270,6 +257,10 @@ <h5 class="text-light text-center">{% trans 'Check the university calender' %}</
</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 %}
Expand Down

0 comments on commit 6f082c0

Please sign in to comment.