Skip to content

Commit 20f5a46

Browse files
committed
fix clubs categories breaking
1 parent f001816 commit 20f5a46

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

backend/apps/clubs/views.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Views for the clubs app.
33
"""
44

5+
import json
56
from rest_framework import status
67
from rest_framework.decorators import api_view, permission_classes, throttle_classes
78
from rest_framework.permissions import AllowAny
@@ -35,18 +36,24 @@ def get_clubs(request):
3536
)
3637

3738
# Convert to list of dictionaries
38-
clubs_data = [
39-
{
39+
clubs_data = []
40+
for club in filtered_queryset:
41+
# Handle categories - parse JSON if it's a string, otherwise use as-is
42+
categories = club.categories
43+
if isinstance(categories, str):
44+
categories = json.loads(categories)
45+
else:
46+
categories = []
47+
48+
clubs_data.append({
4049
"id": club.id,
4150
"club_name": club.club_name,
42-
"categories": club.categories,
51+
"categories": categories,
4352
"club_page": club.club_page,
4453
"ig": club.ig,
4554
"discord": club.discord,
4655
"club_type": club.club_type,
47-
}
48-
for club in filtered_queryset
49-
]
56+
})
5057

5158
return Response({"clubs": clubs_data})
5259
except Exception as e:

backend/scraping/wusa_club_directory_scraper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def scrape_all():
133133
res.append(
134134
{
135135
"club_name": club_info["club_name"],
136-
"categories": "; ".join(club_info["categories"]),
136+
"categories": club_info["categories"],
137137
"club_page": club_info["club_page"],
138138
"ig": club_info["ig"],
139139
"discord": club_info["discord"],

0 commit comments

Comments
 (0)