38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
from django.urls import path, include
|
||
from rest_framework.routers import DefaultRouter
|
||
|
||
from apps.common.api.auto_router import auto_register
|
||
from apps.common.views import HealthCheckView
|
||
from apps.content.views import ArticleViewSet
|
||
from apps.courses.views import CourseViewSet
|
||
|
||
# Action-based Views (Enrollment / Progress)
|
||
from apps.courses.views import (
|
||
EnrollCourseView,
|
||
MyCoursesView,
|
||
CompleteLessonView,
|
||
)
|
||
|
||
# Router สำหรับ CMS-like API
|
||
router = DefaultRouter()
|
||
|
||
# ใช้ auto_register เฉพาะกับ CMS‑like resources
|
||
auto_register(router, {
|
||
"articles" : ArticleViewSet,
|
||
"courses" : CourseViewSet,
|
||
})
|
||
|
||
urlpatterns = [
|
||
# Health check
|
||
path("health/", HealthCheckView.as_view(), name="health-check"),
|
||
|
||
# CMS-like API
|
||
path("api/", include(router.urls)),
|
||
|
||
# Enrollment (user ↔ course)
|
||
path("api/courses/<int:course_id>/enroll/", EnrollCourseView.as_view(), name="enroll-course"),
|
||
path("api/my/courses/", MyCoursesView.as_view(), name="my-courses"),
|
||
|
||
# Progress tracking (user ↔ lesson)
|
||
path("api/lessons/<int:lesson_id>/complete/", CompleteLessonView.as_view(), name="complete-lesson"),
|
||
] |