Skip to content

Commit d7b671a

Browse files
authored
Merge pull request #132 from cmu-delphi/OKRS24-192-Signal-Detail-Add-a-list-of-signals-with-the-same-base-signal
[OKRS24-192] Signal Detail Added a list of signals with the same base signal
2 parents 127aacd + b123c3c commit d7b671a

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

src/signals/models.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,13 @@ def example_url(self):
302302
example_url = self.links.filter(link_type="example_url").first()
303303
return example_url.url if example_url else None
304304

305+
@property
306+
def same_base_signals(self):
307+
"""
308+
Returns the signals that have the same base signal.
309+
"""
310+
return self.base.base_for.all() if self.base else None
311+
305312
class Meta:
306313
unique_together = ['name', 'source']
307314
ordering: list[str] = ["modified"]

src/templates/signals/signal_detail.html

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,80 @@ <h5>About this signal</h5>
207207
</div>
208208
</div>
209209
</section>
210+
{% if signal.base %}
211+
<h5>Signals with same base</h5>
212+
<section class="section">
213+
<div class="row">
214+
<div class="card">
215+
<div class="card-body">
216+
<table class="table table-borderless table-hover">
217+
<thead>
218+
<tr>
219+
<th scope="col">Name</th>
220+
<th scope="col">Active</th>
221+
<th scope="col">Data Source</th>
222+
<th scope="col">Description</th>
223+
<th scope="col">Pathogen/Disease Area</th>
224+
<th scope="col">Base Signal</th>
225+
<th scope="col">Last Updated</th>
226+
</tr>
227+
</thead>
228+
<tbody>
229+
{% for signal in signal.same_base_signals %}
230+
<tr classs="clickable-table-row">
231+
<td onClick="location.href='{% url 'signal' pk=signal.id %}';" class="clickable-table-cell">{{ signal.display_name }}</td>
232+
{% if signal.active == True %}
233+
<td><i class="bi bi-circle-fill" style="color:green;" ></i></td>
234+
{% else %}
235+
<td><i class="bi bi-circle-fill" style="color:red;" ></i></td>
236+
{% endif %}
237+
<td>{{ signal.source.data_source }}</td>
238+
<td>{{ signal.description }}</td>
239+
<td>
240+
{% for pathogen in signal.pathogen.all %}
241+
<span class="badge rounded-pill bg-dark">{{ pathogen|title }}</span>
242+
{% endfor %}
243+
</td>
244+
<td>
245+
{% if signal.base %}
246+
<a href="{% url 'signal' pk=signal.base.id %}">{{ signal.display_name }}</a>
247+
{% else %}
248+
--/--
249+
{% endif %}
250+
</td>
251+
<td>
252+
{% if signal.last_updated %}
253+
{{ signal.last_updated|date:"Y-m-d" }}
254+
{% else %}
255+
--/--
256+
{% endif %}
257+
</td>
258+
</tr>
259+
{% endfor %}
260+
</tbody>
261+
</table>
262+
</div>
263+
</div>
264+
</div>
265+
</section>
266+
{% endif %}
267+
{% if signal.example_url != '' %}
268+
<h5>Response Example</h5>
269+
<section class="section">
270+
<div class="row">
271+
<div class="card">
272+
<div class="card-body">
273+
<div class="row margin-top-1rem">
274+
<p>Example URL:</p>
275+
<span>{{ signal.example_url }}</span>
276+
<button type="button" class="btn btn-primary margin-top-1rem" id="show-response">Show response</button>
277+
<pre class="margin-top-1rem"><code id="example-response" class="hidden"></code></pre>
278+
</div>
279+
</div>
280+
</div>
281+
</div>
282+
</section>
283+
{% endif %}
210284
{% include "signals/data_visualization_export.html"%}
211285
<h5>Related links</h5>
212286
<section class="section">

0 commit comments

Comments
 (0)