Add URL routes + stubs for work log payroll cross-link
Routes /history/<id>/ and /history/<id>/payroll/ajax/ to stub views. Both admin-gated; no data yet. Sets up the surface for Tasks 2-4. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0ec3f66739
commit
b4c3109c29
@ -18,6 +18,13 @@ urlpatterns = [
|
||||
# CSV export — downloads filtered work logs as a spreadsheet
|
||||
path('history/export/', views.export_work_log_csv, name='export_work_log_csv'),
|
||||
|
||||
# === WORK LOG PAYROLL CROSS-LINK (admin-only) ===
|
||||
# Click a historic work log -> see who got paid and who didn't.
|
||||
# AJAX endpoint returns JSON (the modal builds its own DOM safely);
|
||||
# detail view renders the same data as a shareable full page.
|
||||
path('history/<int:log_id>/', views.work_log_payroll_detail, name='work_log_payroll_detail'),
|
||||
path('history/<int:log_id>/payroll/ajax/', views.work_log_payroll_ajax, name='work_log_payroll_ajax'),
|
||||
|
||||
# CSV export — downloads all worker data (admin only)
|
||||
path('workers/export/', views.export_workers_csv, name='export_workers_csv'),
|
||||
|
||||
|
||||
@ -720,6 +720,44 @@ def work_history(request):
|
||||
return render(request, 'core/work_history.html', context)
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# === WORK LOG PAYROLL CROSS-LINK ===
|
||||
# From any historic work log, see which workers got paid, which didn't, and
|
||||
# (for paid ones) which payslip it was. Admin-only; supervisors never see
|
||||
# payroll data. Two endpoints share one helper so the modal and the full
|
||||
# page can never drift apart.
|
||||
# =============================================================================
|
||||
|
||||
def _build_work_log_payroll_context(log):
|
||||
"""Return a context dict describing the payroll status of a work log.
|
||||
|
||||
Used by both the AJAX modal endpoint and the full-page detail view so
|
||||
they always show identical data. See Task 2 for the full implementation.
|
||||
"""
|
||||
# Stub — implemented in Task 2
|
||||
return {'log': log}
|
||||
|
||||
|
||||
@login_required
|
||||
def work_log_payroll_ajax(request, log_id):
|
||||
"""Return JSON describing the payroll status of a work log."""
|
||||
# Stub — implemented in Task 3
|
||||
if not is_admin(request.user):
|
||||
return JsonResponse({'error': 'Not authorized'}, status=403)
|
||||
get_object_or_404(WorkLog, id=log_id)
|
||||
return JsonResponse({'stub': True})
|
||||
|
||||
|
||||
@login_required
|
||||
def work_log_payroll_detail(request, log_id):
|
||||
"""Render the full payroll-status page for a single work log."""
|
||||
# Stub — implemented in Task 4
|
||||
if not is_admin(request.user):
|
||||
return HttpResponseForbidden("Admin access required.")
|
||||
log = get_object_or_404(WorkLog, id=log_id)
|
||||
return HttpResponse(f"<p>stub for log {log.id}</p>")
|
||||
|
||||
|
||||
# === CSV EXPORT ===
|
||||
# Downloads the filtered work log history as a CSV file.
|
||||
# Uses the same filters as the work_history page.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user