fix: 4 more bugs from extended URL sweep (123 pages tested)
All checks were successful
Build and Push Docker Image / build (push) Successful in 2m13s

1. /complaints/templates/ — FieldError: order_by('name_en') on ComplaintTemplate
   model which has 'name' (not 'name_en'). Fixed.
2. /executive/* (4 URLs) — NoReverseMatch: redirect('core:home') referenced a
   non-existent URL name. Fixed to redirect('/').
3. /my/ and /my/performance/ — ValueError: QIProjectTask.filter(assigned_to=user)
   passed a User to a Staff FK. Fixed to use user.staff_profile.
4. /organizations/hospitals/ — FieldError: Hospital.objects.filter(hospital=...)
   on a self-referential field that doesn't exist. Fixed to filter by pk.
This commit is contained in:
ismail 2026-06-17 20:42:06 +03:00
parent e9dfd3b2a5
commit 50a41f9f3c
4 changed files with 12 additions and 8 deletions

View File

@ -34,9 +34,9 @@ def template_list(request):
# Search # Search
search = request.GET.get('search') search = request.GET.get('search')
if search: if search:
templates = templates.filter(name_en__icontains=search) templates = templates.filter(name__icontains=search)
templates = templates.order_by('-usage_count', 'name_en') templates = templates.order_by('-usage_count', 'name')
# Get hospitals for filter # Get hospitals for filter
if request.user.is_px_admin(): if request.user.is_px_admin():

View File

@ -893,7 +893,11 @@ def get_dashboard_chart_data(user, start_date=None, selected_hospital=None):
action_qs = action_qs.filter(hospital=selected_hospital) action_qs = action_qs.filter(hospital=selected_hospital)
completed_count += action_qs.count() completed_count += action_qs.count()
task_qs = QIProjectTask.objects.filter(assigned_to=user, status="closed", completed_date=date.date()) staff_profile = getattr(user, 'staff_profile', None)
if staff_profile:
task_qs = QIProjectTask.objects.filter(assigned_to=staff_profile, status="closed", completed_date=date.date())
else:
task_qs = QIProjectTask.objects.none()
if selected_hospital: if selected_hospital:
task_qs = task_qs.filter(project__hospital=selected_hospital) task_qs = task_qs.filter(project__hospital=selected_hospital)
completed_count += task_qs.count() completed_count += task_qs.count()

View File

@ -42,7 +42,7 @@ class ExecutiveAccessMixin:
return redirect("accounts:login") return redirect("accounts:login")
if not (request.user.is_executive() or request.user.is_px_admin()): if not (request.user.is_executive() or request.user.is_px_admin()):
messages.error(request, _("You do not have permission to access the executive dashboard.")) messages.error(request, _("You do not have permission to access the executive dashboard."))
return redirect("core:home") return redirect("/")
return super().dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)

View File

@ -28,16 +28,16 @@ def hospital_list(request):
if user.is_px_admin(): if user.is_px_admin():
# PX Admins see only their selected tenant hospital # PX Admins see only their selected tenant hospital
if request.tenant_hospital: if request.tenant_hospital:
queryset = queryset.filter(hospital=request.tenant_hospital) queryset = queryset.filter(pk=request.tenant_hospital.pk)
else: else:
queryset = queryset.none() queryset = queryset.none()
elif user.hospital: elif user.hospital:
queryset = queryset.filter(hospital=user.hospital) queryset = queryset.filter(pk=user.hospital_id)
# Apply filters # Apply filters
hospital_filter = request.GET.get("hospital") hospital_filter = request.GET.get("hospital")
if hospital_filter: if hospital_filter:
queryset = queryset.filter(hospital_id=hospital_filter) queryset = queryset.filter(pk=hospital_filter)
status_filter = request.GET.get("status") status_filter = request.GET.get("status")
if status_filter: if status_filter:
@ -51,7 +51,7 @@ def hospital_list(request):
) )
# Ordering # Ordering
queryset = queryset.order_by("hospital", "name") queryset = queryset.order_by("name")
# Pagination # Pagination
page_size = int(request.GET.get("page_size", 25)) page_size = int(request.GET.get("page_size", 25))