From a367685b2e349e381de2c2f456fbfbb6c0f1ac07 Mon Sep 17 00:00:00 2001 From: Zareian Date: Wed, 2 Sep 2026 11:04:47 +0330 Subject: [PATCH] expose per-node lessonIds in GET /api/home The skill-map response gave units -> nodes with id/title/status but no way to map a node to its lessons, and no other endpoint fills that gap (/api/progress/nodes doesn't either). Any client rendering the map needs this to know which lesson to open when a node is tapped. The ids are already computed in the cached _grade_tree; this just surfaces them. Additive and backward-compatible; content tests pass. Co-Authored-By: Claude Sonnet 5 --- content/serializers.py | 3 +++ content/views.py | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/content/serializers.py b/content/serializers.py index 39c4820..c299f63 100644 --- a/content/serializers.py +++ b/content/serializers.py @@ -22,6 +22,9 @@ class NodeStatusSerializer(serializers.Serializer): id = serializers.CharField() title = serializers.CharField() status = serializers.ChoiceField(choices=['locked', 'unlocked', 'completed']) + # شناسه‌ی درس‌های همین گره تا کلاینت بدونه با کلیک روی گره کدوم درس رو + # باز کنه (endpointهای lessons/{id}/... مستقیم با همین id کار می‌کنن). + lessonIds = serializers.ListField(child=serializers.IntegerField()) class UnitWithNodesSerializer(serializers.Serializer): diff --git a/content/views.py b/content/views.py index 91f8f23..675ce70 100644 --- a/content/views.py +++ b/content/views.py @@ -183,7 +183,12 @@ class HomeView(APIView): node_status = _node_status(node['lesson_ids'], completed_ids, unlock_next) if node_status != 'completed': unlock_next = False - node_payload.append({'id': node['id'], 'title': node['title'], 'status': node_status}) + node_payload.append({ + 'id': node['id'], + 'title': node['title'], + 'status': node_status, + 'lessonIds': node['lesson_ids'], + }) units_payload.append({'id': unit['id'], 'title': unit['title'], 'nodes': node_payload}) stats = UserStats.objects.filter(user_id=user_id).first()