diff --git a/course_discovery/apps/tagging/templates/partials/subvertical_options.html b/course_discovery/apps/tagging/templates/partials/subvertical_options.html
index 7b8ed00e22..d27760c377 100644
--- a/course_discovery/apps/tagging/templates/partials/subvertical_options.html
+++ b/course_discovery/apps/tagging/templates/partials/subvertical_options.html
@@ -1,4 +1,4 @@
-
+
{% for sub_vertical in sub_verticals %}
{% endfor %}
diff --git a/course_discovery/apps/tagging/views.py b/course_discovery/apps/tagging/views.py
index 91b93c7909..73d8e2aa75 100644
--- a/course_discovery/apps/tagging/views.py
+++ b/course_discovery/apps/tagging/views.py
@@ -1,9 +1,9 @@
-from django.shortcuts import render, get_object_or_404, redirect
from django.core.paginator import Paginator
-from django.http import JsonResponse
-from course_discovery.apps.tagging.models import Vertical, SubVertical, CourseVertical, Course
+from django.http import HttpResponse, JsonResponse
+from django.shortcuts import get_object_or_404, redirect, render
from django.template.loader import render_to_string
-from django.http import HttpResponse
+
+from course_discovery.apps.tagging.models import Course, CourseVertical, SubVertical, Vertical
def course_detail(request, uuid):
@@ -19,22 +19,20 @@ def course_detail(request, uuid):
sub_vertical = SubVertical.objects.filter(slug=sub_vertical_slug).first() if sub_vertical_slug else None
if sub_vertical and sub_vertical.vertical != vertical:
- if request.htmx:
- html = render_to_string("partials/message.html", {
- "error": "Sub-vertical does not belong to the selected vertical."
- }, request)
- return HttpResponse(html, status=200)
+ html = render_to_string("partials/message.html", {
+ "error": "Sub-vertical does not belong to the selected vertical."
+ }, request)
+ return HttpResponse(html, status=200)
CourseVertical.objects.update_or_create(
course=course,
defaults={"vertical": vertical, "sub_vertical": sub_vertical}
)
- if request.htmx:
- html = render_to_string("partials/message.html", {
- "success": "Vertical and Sub-Vertical assigned successfully."
- }, request)
- return HttpResponse(html, status=200)
+ html = render_to_string("partials/message.html", {
+ "success": "Vertical and Sub-Vertical assigned successfully."
+ }, request)
+ return HttpResponse(html, status=200)
return render(request, "tagging/course_detail.html", {
"course": course,
@@ -54,10 +52,6 @@ def load_subverticals(request):
return JsonResponse({"html": html})
-from django.http import HttpResponse
-from django.template.loader import render_to_string
-from .models import Course
-
def course_list(request):
search_query = request.GET.get('search', '')
sort_by = request.GET.get('sort', 'title')
@@ -75,16 +69,14 @@ def course_list(request):
page_number = request.GET.get('page')
page_obj = paginator.get_page(page_number)
- # If HTMX request, return just the HTML fragment for the table and pagination
if request.headers.get('HX-Request'):
html = render_to_string('partials/course_table.html', {
'courses': page_obj,
'current_sort': sort_by.lstrip('-'),
'current_direction': direction,
})
- return HttpResponse(html) # Return raw HTML, not wrapped in JsonResponse
+ return HttpResponse(html)
- # Normal response if not an HTMX request
return render(request, "tagging/course_list.html", {
"courses": page_obj,
"current_sort": sort_by.lstrip('-'),
@@ -108,7 +100,6 @@ def vertical_list(request):
})
-
def subvertical_list(request):
"""
Renders a list of all SubVerticals with their parent Verticals and assigned Courses.