Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions src/alternative_interface/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.shortcuts import render
from indicators.models import Indicator
from base.models import Pathogen
from base.models import Pathogen, Geography


HEADER_DESCRIPTION = "Discover, display and download real-time infectious disease indicators (time series) that track a variety of pathogens, diseases and syndromes in a variety of locations (primarily within the USA). Browse the list, or filter it first by locations and pathogens of interest, by surveillance categories, and more. Expand any row to expose and select from a set of related indicators, then hit 'Show Selected Indicators' at bottom to plot or export your selected indicators, or to generate code snippets to retrieve them from the Delphi Epidata API. Most indicators are served from the Delphi Epidata real-time repository, but some may be available only from third parties or may require prior approval."
Expand All @@ -18,16 +18,28 @@ def alternative_interface_view(request):
)
)

# Get pathogen filter from URL parameters
# Fetch geographies for dropdown
ctx["geographies"] = list(
Geography.objects.filter(used_in="indicatorsets").order_by(
"display_order_number"
)
)

# Get filters from URL parameters
pathogen_filter = request.GET.get("pathogen", "")
geography_filter = request.GET.get("geography", "")
ctx["selected_pathogen"] = pathogen_filter
ctx["selected_geography"] = geography_filter

# Build queryset with optional pathogen filtering
indicators_qs = Indicator.objects.prefetch_related("pathogens").all()
# Build queryset with optional filtering
indicators_qs = Indicator.objects.prefetch_related("pathogens", "available_geographies").all()

if pathogen_filter:
indicators_qs = indicators_qs.filter(pathogens__id=pathogen_filter)

if geography_filter:
indicators_qs = indicators_qs.filter(available_geographies__id=geography_filter)

# Convert to list of dictionaries
ctx["indicators"] = [
{
Expand Down
Loading
Loading