from django.urls import path, re_path
from django.contrib.auth.views import LogoutView
from . import views

urlpatterns = [
    path('', views.home_view, name='home'),
    path('login/', views.CustomLoginView.as_view(), name='login'),
    path('register/', views.RegisterView.as_view(), name='register'),
    path('logout/', LogoutView.as_view(next_page='home'), name='logout'),
    path('db-fix/', views.run_migrations_view, name='run_migrations'),



    # Student
    path('dashboard/student/', views.student_dashboard, name='student_dashboard'),
    path('dashboard/student/profile/', views.student_profile_update, name='student_profile_update'),

    # Teacher
    path('dashboard/teacher/', views.teacher_dashboard, name='teacher_dashboard'),
    path('dashboard/teacher/profile/', views.teacher_profile_update, name='teacher_profile_update'),

    # Teacher Public Profile
    path('teacher/<int:teacher_id>/', views.teacher_public_profile, name='teacher_public_profile'),

    # Wiki / Articles — re_path to support Arabic (Unicode) slugs
    path('articles/', views.wiki_list, name='wiki_list'),
    path('articles/new/', views.wiki_create, name='wiki_create'),
    re_path(r'^articles/(?P<slug>[^/]+)/$', views.wiki_detail, name='wiki_detail'),
    re_path(r'^articles/(?P<slug>[^/]+)/edit/$', views.wiki_edit, name='wiki_edit'),
    re_path(r'^articles/(?P<slug>[^/]+)/delete/$', views.wiki_delete, name='wiki_delete'),

    # Courses & Lessons (public)
    path('courses/', views.course_list, name='course_list'),
    path('courses/new/', views.course_create, name='course_create'),
    path('courses/<int:course_id>/', views.course_detail, name='course_detail'),
    path('courses/<int:course_id>/enroll/', views.enroll_course, name='enroll_course'),
    path('courses/<int:course_id>/edit/', views.course_edit, name='course_edit'),
    path('courses/<int:course_id>/manage/', views.course_manage, name='course_manage'),
    path('courses/<int:course_id>/lesson/<int:lesson_id>/', views.lesson_detail, name='lesson_detail'),

    # Lessons management (teacher)
    path('courses/<int:course_id>/lesson/new/', views.lesson_create, name='lesson_create'),
    path('courses/<int:course_id>/lesson/<int:lesson_id>/edit/', views.lesson_edit, name='lesson_edit'),
    path('courses/<int:course_id>/lesson/<int:lesson_id>/delete/', views.lesson_delete, name='lesson_delete'),
    path('lesson/<int:lesson_id>/complete/', views.mark_lesson_complete, name='mark_lesson_complete'),

    # PDF Summaries
    path('summaries/', views.summary_list, name='summary_list'),
    path('summaries/<int:summary_id>/', views.summary_detail, name='summary_detail'),
    path('summaries/<int:summary_id>/buy/', views.summary_buy, name='summary_buy'),
    path('summaries/<int:summary_id>/read/', views.summary_read, name='summary_read'),
]
