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
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:
parent
e9dfd3b2a5
commit
50a41f9f3c
@ -34,9 +34,9 @@ def template_list(request):
|
||||
# Search
|
||||
search = request.GET.get('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
|
||||
if request.user.is_px_admin():
|
||||
|
||||
@ -893,7 +893,11 @@ def get_dashboard_chart_data(user, start_date=None, selected_hospital=None):
|
||||
action_qs = action_qs.filter(hospital=selected_hospital)
|
||||
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:
|
||||
task_qs = task_qs.filter(project__hospital=selected_hospital)
|
||||
completed_count += task_qs.count()
|
||||
|
||||
@ -42,7 +42,7 @@ class ExecutiveAccessMixin:
|
||||
return redirect("accounts:login")
|
||||
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."))
|
||||
return redirect("core:home")
|
||||
return redirect("/")
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
|
||||
|
||||
@ -28,16 +28,16 @@ def hospital_list(request):
|
||||
if user.is_px_admin():
|
||||
# PX Admins see only their selected tenant hospital
|
||||
if request.tenant_hospital:
|
||||
queryset = queryset.filter(hospital=request.tenant_hospital)
|
||||
queryset = queryset.filter(pk=request.tenant_hospital.pk)
|
||||
else:
|
||||
queryset = queryset.none()
|
||||
elif user.hospital:
|
||||
queryset = queryset.filter(hospital=user.hospital)
|
||||
queryset = queryset.filter(pk=user.hospital_id)
|
||||
|
||||
# Apply filters
|
||||
hospital_filter = request.GET.get("hospital")
|
||||
if hospital_filter:
|
||||
queryset = queryset.filter(hospital_id=hospital_filter)
|
||||
queryset = queryset.filter(pk=hospital_filter)
|
||||
|
||||
status_filter = request.GET.get("status")
|
||||
if status_filter:
|
||||
@ -51,7 +51,7 @@ def hospital_list(request):
|
||||
)
|
||||
|
||||
# Ordering
|
||||
queryset = queryset.order_by("hospital", "name")
|
||||
queryset = queryset.order_by("name")
|
||||
|
||||
# Pagination
|
||||
page_size = int(request.GET.get("page_size", 25))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user