HH/apps/appreciation/urls.py
ismail 295ff298a8 refactor(appreciation): collapse to 3-state DRAFT → ACTIVATED → SENT
Drops the dead AI_ANALYZED status (a prior data migration already converted
existing rows; the choice was never removed from the model) and the
unreachable ACKNOWLEDGED status (is_recipient was hardcoded False so the
acknowledge button never rendered).

Changes:
- AppreciationStatus: DRAFT, ACTIVATED, SENT only. SENT is terminal.
- VALID_APPRECIATION_TRANSITIONS: DRAFT→ACTIVATED→SENT, SENT terminal.
- Removed the model.acknowledge() method.
- DRF viewset acknowledge action: returns 410 Gone (deprecated).
- UI appreciation_acknowledge view: redirects with deprecation message.
- Removed URL routes: appreciation_acknowledge, appreciation_send_dept_reminder.
- appreciation_send_dept_reminder status check no longer references ACKNOWLEDGED.
- appreciation_list stats + status filter + badge: dropped ai_analyzed/acknowledged.
- appreciation_detail status badge + sent banner: dropped acknowledged references.
- Migration 0010_drop_acknowledged_status: AlterField on status choices.

AI analysis still runs on activation and is stored in ai_analysis JSON; it
just no longer has its own status. Badges and leaderboard fire at SENT.
6 tests lock in the new lifecycle and removed URLs.
2026-07-20 22:20:29 +03:00

71 lines
3.5 KiB
Python

"""
Appreciation URLs - URL configuration for appreciation API and UI
"""
from django.urls import include, path
from rest_framework.routers import DefaultRouter
from apps.appreciation.views import (
AppreciationBadgeViewSet,
AppreciationCategoryViewSet,
AppreciationStatsViewSet,
AppreciationViewSet,
LeaderboardView,
UserBadgeViewSet,
)
from apps.appreciation import ui_views
router = DefaultRouter()
router.register(r'categories', AppreciationCategoryViewSet, basename='appreciation-category')
router.register(r'appreciations', AppreciationViewSet, basename='appreciation')
router.register(r'stats', AppreciationStatsViewSet, basename='appreciation-stats')
router.register(r'badges', AppreciationBadgeViewSet, basename='appreciation-badge')
router.register(r'user-badges', UserBadgeViewSet, basename='user-badge')
app_name = 'appreciation'
urlpatterns = [
# API Routes
path('api/', include(router.urls)),
path('api/leaderboard/', LeaderboardView.as_view(), name='api-leaderboard'),
# UI Routes
path('', ui_views.appreciation_list, name='appreciation_list'),
path('new/', ui_views.appreciation_create, name='appreciation_create'),
path('detail/<uuid:pk>/', ui_views.appreciation_detail, name='appreciation_detail'),
path('detail/<uuid:pk>/activate/', ui_views.appreciation_activate, name='appreciation_activate'),
path('detail/<uuid:pk>/select-recipient/', ui_views.appreciation_select_recipient, name='appreciation_select_recipient'),
path('detail/<uuid:pk>/send/', ui_views.appreciation_send, name='appreciation_send'),
path('detail/<uuid:pk>/send-to/', ui_views.appreciation_send_to, name='appreciation_send_to'),
path('leaderboard/', ui_views.leaderboard_view, name='leaderboard_view'),
path('badges/', ui_views.my_badges_view, name='my_badges_view'),
# Admin: Category Management
path('admin/categories/', ui_views.category_list, name='category_list'),
path('admin/categories/create/', ui_views.category_create, name='category_create'),
path('admin/categories/<uuid:pk>/edit/', ui_views.category_edit, name='category_edit'),
path('admin/categories/<uuid:pk>/delete/', ui_views.category_delete, name='category_delete'),
# Admin: Badge Management
path('admin/badges/', ui_views.badge_list, name='badge_list'),
path('admin/badges/create/', ui_views.badge_create, name='badge_create'),
path('admin/badges/<uuid:pk>/edit/', ui_views.badge_edit, name='badge_edit'),
path('admin/badges/<uuid:pk>/delete/', ui_views.badge_delete, name='badge_delete'),
# Restore deleted appreciation
path('admin/appreciations/<uuid:pk>/restore/', ui_views.appreciation_restore, name='admin_appreciation_restore'),
# AJAX Helpers
path('ajax/users/', ui_views.get_users_by_hospital, name='get_users_by_hospital'),
path('ajax/staff/', ui_views.get_staff_by_hospital, name='get_staff_by_hospital'),
path('ajax/physicians/', ui_views.get_physicians_by_hospital, name='get_physicians_by_hospital'),
path('ajax/departments/', ui_views.get_departments_by_hospital, name='get_departments_by_hospital'),
path('ajax/summary/', ui_views.appreciation_summary_ajax, name='appreciation_summary_ajax'),
# Public submission (no auth required)
path('public/submit/', ui_views.public_appreciation_submit, name='public_appreciation_submit'),
# PDF downloads (require activation)
path('detail/<uuid:pk>/letter/', ui_views.appreciation_letter, name='appreciation_letter'),
path('detail/<uuid:pk>/certificate/', ui_views.appreciation_certificate, name='appreciation_certificate'),
]