From fdc2dd853dfc6abd8af87f4bd8a9c55bdfa6a33f Mon Sep 17 00:00:00 2001 From: Dmytro Trotsko Date: Sat, 21 Dec 2024 10:23:56 +0200 Subject: [PATCH] Updated Signal Sets list view --- src/signal_sets/views.py | 31 +- src/templates/index.html | 8 + src/templates/signal_sets/signal_sets.html | 390 +++++++++++---------- 3 files changed, 238 insertions(+), 191 deletions(-) diff --git a/src/signal_sets/views.py b/src/signal_sets/views.py index b51376d..41480b0 100644 --- a/src/signal_sets/views.py +++ b/src/signal_sets/views.py @@ -1,5 +1,6 @@ import logging from typing import Any, Dict +import json from django.conf import settings from django.db.models.query import QuerySet @@ -58,17 +59,37 @@ def get_url_params(self): url_params_str = f"{url_params_str}&{param_name}={param_value}" return url_params_dict, url_params_str + def get_related_signals(self): + related_signals = [] + for signal_set in self.get_queryset(): + for signal in signal_set.signals.all(): + related_signals.append( + { + "id": signal.id, + "display_name": signal.display_name, + "name": signal.name, + "signal_set": signal_set.id, + "signal_set_name": signal_set.name, + "endpoint": signal_set.endpoint, + "source": signal.source.name, + "time_type": signal.time_type, + "description": signal.description + } + ) + return related_signals + def get_context_data(self, **kwargs: Any) -> dict[str, Any]: context = super().get_context_data(**kwargs) url_params_dict, url_params_str = self.get_url_params() context["url_params_dict"] = url_params_dict context["url_params_str"] = url_params_str - context['epivis_url'] = settings.EPIVIS_URL + context["epivis_url"] = settings.EPIVIS_URL context["form"] = SignalSetFilterForm(initial=url_params_dict) context["filter"] = SignalSetFilter( self.request.GET, queryset=self.get_queryset() ) context["signal_sets"] = self.get_queryset() + context["related_signals"] = json.dumps(self.get_related_signals()) context["available_geographies"] = Geography.objects.all() return context @@ -96,6 +117,12 @@ def get_context_data(self, **kwargs: Any) -> dict[str, Any]: .distinct() .order_by() ) - context["time_type"] = self.object.signals.all().values_list("time_type", flat=True).distinct().order_by().first() + context["time_type"] = ( + self.object.signals.all() + .values_list("time_type", flat=True) + .distinct() + .order_by() + .first() + ) return context diff --git a/src/templates/index.html b/src/templates/index.html index db96a4a..6656a43 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -41,6 +41,11 @@ + + + + + @@ -312,6 +317,9 @@ + + + diff --git a/src/templates/signal_sets/signal_sets.html b/src/templates/signal_sets/signal_sets.html index 58c278f..23a7e60 100644 --- a/src/templates/signal_sets/signal_sets.html +++ b/src/templates/signal_sets/signal_sets.html @@ -240,188 +240,120 @@

-
-
-
- - Showing {{ signal_sets|length }} Signal Set{{ signal_sets|length|pluralize:"s" }}. - -
-
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {% for signal_set in signal_sets %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {% endfor %} - -
Name Pathogen(s)/Syndrome(s)Type(s) of DataGeographic ScopeGeographic GranularityTemporal scope StartTemporal Scope EndTemporal GranularityReporting CadenceReporting Lag(nominal)Revision CadenceDemographic scopeDemographic GranularitySeverity Pyramid Rung(s)Data SourcePre-processingCensoringMissingnessDUA requiredLicenseDocumentation
- - - {{ signal_set.name }} - - - {% for pathogen in signal_set.pathogens.all %} - - {{ pathogen }} - - {% endfor %} - - {{ signal_set.data_type }} - - {{ signal_set.geographic_scope }} - - {{ signal_set.geographic_granularity }} - - {{ signal_set.temporal_scope_start }} - - {{ signal_set.temporal_scope_end }} - - {{ signal_set.temporal_granularity }} -
-
- {{ signal_set.reporting_cadence }} -
-
- {{ signal_set.reporting_lag }} -
-
- {{ signal_set.revision_cadence }} -
-
- {{ signal_set.demographic_scope }} -
-
- {{ signal_set.demographic_granularity }} -
-
- {% for severity_pyramid_rung in signal_set.severity_pyramid_rungs.all %} - - {{ severity_pyramid_rung }} - - {% endfor %} - - {{ signal_set.data_source }} - - {{ signal_set.preprocessing_description }} - - {{ signal_set.censoring }} -
-
- {{ signal_set.missingness }} -
-
- {{ signal_set.dua_required }} -
-
- {{ signal_set.license }} -
-
- {{ signal_set.link_to_documentation }} -
-
-
- - - - - - - - - {% for signal in signal_set.signals.all %} - - - - - - {% endfor %} - -
- Select Signal Set Members -
Signal NameSignal description
- - - {{ signal.member_name}} - - {{ signal.member_description }} -
-
-
-
-
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + {% for signal_set in signal_sets %} + + + + + + + + + + + + + + + + + + + + + + + + + {% endfor %} + +
Name Pathogen(s)/Syndrome(s)Type(s) of DataGeographic ScopeGeographic GranularityTemporal scope StartTemporal Scope EndTemporal GranularityReporting CadenceReporting Lag(nominal)Revision CadenceDemographic scopeDemographic GranularitySeverity Pyramid Rung(s)Data SourcePre-processingCensoringMissingnessDUA requiredLicenseDocumentation
+ {{ signal_set.name }} + + {% for pathogen in signal_set.pathogens.all %} + + {{ pathogen }} + + {% endfor %} + + {{ signal_set.data_type }} + + {{ signal_set.geographic_scope }} + + {{ signal_set.geographic_granularity }} + + {{ signal_set.temporal_scope_start }} + + {{ signal_set.temporal_scope_end }} + + {{ signal_set.temporal_granularity }} + + {{ signal_set.reporting_cadence }} + + {{ signal_set.reporting_lag }} + + {{ signal_set.revision_cadence }} + + {{ signal_set.demographic_scope }} + + {{ signal_set.demographic_granularity }} + + {% for severity_pyramid_rung in signal_set.severity_pyramid_rungs.all %} + + {{ severity_pyramid_rung }} + + {% endfor %} + + {{ signal_set.data_source }} + + {{ signal_set.preprocessing_description }} + + {{ signal_set.censoring }} + + {{ signal_set.missingness }} + + {{ signal_set.dua_required }} + + {{ signal_set.license }} + + {{ signal_set.link_to_documentation }} +
+ +