from django.urls import path
from . import views

# Se mantienen los nombres de ruta del proyecto original para coherencia.
# El orden importa: las rutas con literales (topic/create/edit/post) van antes
# que la genérica forum/<int:forum_id>/...
urlpatterns = [
    path('forum', views.index, name='app_forum'),
    path('forum/search', views.search, name='forum_search'),

    # Temas
    path('forum/topic/<int:topic_id>/reply', views.reply_to_topic, name='forum_post_reply'),
    path('forum/topic/<int:topic_id>/move', views.move_topic, name='forum_move_topic'),
    path('forum/topic/<int:topic_id>/lock', views.lock_topic, name='forum_lock_topic'),
    path('forum/topic/<int:topic_id>/unlock', views.unlock_topic, name='forum_unlock_topic'),
    path('forum/topic/<int:topic_id>/sticky', views.toggle_sticky, name='forum_toggle_sticky'),
    path('forum/topic/<int:topic_id>/restore', views.restore_topic, name='forum_restore_topic'),
    path('forum/topic/delete/<int:topic_id>', views.delete_topic, name='forum_delete_topic'),
    path('forum/topic/<int:topic_id>/<int:page>', views.view_topic, name='forum_topic'),
    path('forum/topic/<int:topic_id>', views.view_topic, name='forum_topic_p1'),

    # Posts
    path('forum/post/update/<int:post_id>', views.update_post, name='forum_update_post'),
    path('forum/post/delete/<int:post_id>', views.delete_post, name='forum_delete_post'),
    path('forum/post/<int:post_id>/restore', views.restore_post, name='forum_restore_post'),
    path('forum/edit/<int:post_id>', views.edit_post, name='forum_edit_post'),

    # Crear tema
    path('forum/create/<int:forum_id>/submit', views.submit_create_topic, name='forum_create_topic_submit'),
    path('forum/create/<int:forum_id>', views.create_topic, name='forum_create_topic'),

    # Ver foro (paginado) — genérica, al final
    path('forum/<int:forum_id>/<int:page>', views.view_forum, name='forum_view'),
    path('forum/<int:forum_id>', views.view_forum, name='forum_view_p1'),

    # Perfil público
    path('profile/<str:username>', views.profile, name='forum_profile'),
]
