From bd1634b4e490695e99dea4f88a019f35c1a80166 Mon Sep 17 00:00:00 2001 From: Dan Avner Date: Wed, 18 Oct 2023 11:38:53 -0700 Subject: [PATCH] Add ability to navaigate to specific tab in target view. --- .../partials/observation_list.html | 3 +- tom_observations/views.py | 6 ++-- .../templates/tom_targets/target_detail.html | 30 +++++++++++-------- tom_targets/views.py | 2 +- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/tom_observations/templates/tom_observations/partials/observation_list.html b/tom_observations/templates/tom_observations/partials/observation_list.html index 8013053d8..0e0c13feb 100644 --- a/tom_observations/templates/tom_observations/partials/observation_list.html +++ b/tom_observations/templates/tom_observations/partials/observation_list.html @@ -1,9 +1,10 @@ - + {% for observation in observations %} + diff --git a/tom_observations/views.py b/tom_observations/views.py index 99edb7aff..1d9e1b53a 100644 --- a/tom_observations/views.py +++ b/tom_observations/views.py @@ -462,9 +462,9 @@ def form_valid(self, form): ) observation_id = form.cleaned_data['observation_id'] messages.success(self.request, f'Successfully associated observation record {observation_id}') - return redirect(reverse( - 'tom_targets:detail', kwargs={'pk': form.cleaned_data['target_id']}) - ) + base_url = reverse('tom_targets:detail', kwargs={'pk': form.cleaned_data['target_id']}) + query_params = urlencode({'tab': 'observations'}) + return redirect(f'{base_url}?{query_params}') class ObservationRecordDetailView(DetailView): diff --git a/tom_targets/templates/tom_targets/target_detail.html b/tom_targets/templates/tom_targets/target_detail.html index 5fdac4eac..ad82b6ed7 100644 --- a/tom_targets/templates/tom_targets/target_detail.html +++ b/tom_targets/templates/tom_targets/target_detail.html @@ -7,18 +7,24 @@ {% endblock %} {% block content %} @@ -39,7 +45,7 @@ {% if object.type == 'SIDEREAL' %} {% aladin object %} {% endif %} - +
diff --git a/tom_targets/views.py b/tom_targets/views.py index ac7d39bfb..9bbc942f0 100644 --- a/tom_targets/views.py +++ b/tom_targets/views.py @@ -435,7 +435,7 @@ def get(self, request, *args, **kwargs): 'Did you know updating observation statuses can be automated? Learn how in' '' ' the docs.')) - return redirect(reverse('tom_targets:detail', args=(target_id,))) + return redirect(reverse('tom_targets:detail', args=(target_id,)) + '?tab=observations') obs_template_form = ApplyObservationTemplateForm(request.GET) if obs_template_form.is_valid():
FacilityCreatedStatusScheduledSaved dataView
FacilityObservation IDCreatedStatusScheduledSaved dataView
{{ observation.facility }}{{ observation.observation_id }} {{ observation.created }} {{ observation.status }} {{ observation.scheduled_start }}