Skip to content

Commit 56fb774

Browse files
authored
Merge pull request #182 from cmu-delphi/development
Development
2 parents c546035 + 082cc8f commit 56fb774

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+10786
-1739
lines changed

src/alternative_interface/__init__.py

Whitespace-only changes.

src/alternative_interface/admin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.

src/alternative_interface/apps.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class AlternativeInterfaceConfig(AppConfig):
5+
default_auto_field = "django.db.models.BigAutoField"
6+
name = "alternative_interface"

src/alternative_interface/migrations/__init__.py

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.db import models
2+
3+
# Create your models here.

src/alternative_interface/urls.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from django.urls import path
2+
from django.urls.resolvers import URLPattern
3+
from alternative_interface.views import alternative_interface_view
4+
5+
urlpatterns: list[URLPattern] = [
6+
path("alternative_interface", alternative_interface_view, name="alternative_interface"),
7+
]

src/alternative_interface/views.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
from django.shortcuts import render
2+
from indicators.models import Indicator
3+
from base.models import Pathogen
4+
5+
6+
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."
7+
8+
9+
def alternative_interface_view(request):
10+
try:
11+
ctx = {}
12+
ctx["header_description"] = HEADER_DESCRIPTION
13+
14+
# Fetch pathogens for dropdown
15+
ctx["pathogens"] = list(
16+
Pathogen.objects.filter(used_in="indicators").order_by(
17+
"display_order_number"
18+
)
19+
)
20+
21+
# Get pathogen filter from URL parameters
22+
pathogen_filter = request.GET.get("pathogen", "")
23+
ctx["selected_pathogen"] = pathogen_filter
24+
25+
# Build queryset with optional pathogen filtering
26+
indicators_qs = Indicator.objects.prefetch_related("pathogens").all()
27+
28+
if pathogen_filter:
29+
indicators_qs = indicators_qs.filter(pathogens__id=pathogen_filter)
30+
31+
# Convert to list of dictionaries
32+
ctx["indicators"] = [
33+
{
34+
"id": indicator.id,
35+
"name": indicator.name,
36+
"source": indicator.source.name if indicator.source else "Unknown",
37+
"geographic_scope": indicator.geographic_scope.name if indicator.geographic_scope else "Unknown",
38+
"temporal_scope_end": indicator.temporal_scope_end,
39+
"description": indicator.description,
40+
"pathogens": [pathogen.name for pathogen in indicator.pathogens.all()],
41+
}
42+
for indicator in indicators_qs
43+
]
44+
45+
return render(
46+
request, "alternative_interface/alter_dashboard.html", context=ctx
47+
)
48+
except Exception as e:
49+
from django.http import HttpResponse
50+
51+
return HttpResponse(f"Error loading page: {str(e)}")

0 commit comments

Comments
 (0)