diff --git a/atdb/taskdatabase/templates/taskdatabase/index.html b/atdb/taskdatabase/templates/taskdatabase/index.html index 149f384b991cca287c175f0e4f66d18f2f45cac7..b982c513b9e3c004d5d99ebe67871e3684564713 100644 --- a/atdb/taskdatabase/templates/taskdatabase/index.html +++ b/atdb/taskdatabase/templates/taskdatabase/index.html @@ -31,7 +31,7 @@ {% include 'taskdatabase/pagination.html' %} </div> </div> - <p class="footer"> Version 12 Mar 2024 + <p class="footer"> Version 19 Mar 2024 </div> {% include 'taskdatabase/refresh.html' %} diff --git a/atdb/taskdatabase/urls.py b/atdb/taskdatabase/urls.py index b846c15dcf892c1cfd9ba1dbc854ea4b46acec19..8197a156896420b5850ab71f0036d5db6dc875e3 100644 --- a/atdb/taskdatabase/urls.py +++ b/atdb/taskdatabase/urls.py @@ -101,6 +101,10 @@ urlpatterns = [ path('get_unique_values_for_key/<str:aggregation_key>/', views.GetUniqueValuesForKey.as_view(), name='get-unique-values-for-key-view'), + # ancillary dataproducts endpoints (retrieved by archiver service for copy to LTA dcache). + path('get_summary_html/<sas_id>', views.GetSummaryHtml, name='get-summary-html'), + path('get_summary_json/<sas_id>', views.GetSummaryJson, name='get-summary-json'), + # --- controller resources --- path('tasks/<int:pk>/setstatus/<new_status>/<page>', views.TaskSetStatus, name='task-setstatus-view'), path('tasks/<int:pk>/setstatus/<new_status>', views.TaskSetStatus, name='task-details-setstatus'), diff --git a/atdb/taskdatabase/views.py b/atdb/taskdatabase/views.py index ffb7a79b57aac6ecc8eada10b7ca026428e6da4d..de0520ad734d990c4060b5d6e5d50d01652ea73b 100644 --- a/atdb/taskdatabase/views.py +++ b/atdb/taskdatabase/views.py @@ -17,7 +17,7 @@ from django.contrib import messages from rest_framework import generics from rest_framework.response import Response -from django.http import JsonResponse +from django.http import JsonResponse, HttpResponse from django_filters import rest_framework as filters from django_filters.views import FilterView @@ -1701,6 +1701,84 @@ class GetUniqueValuesForKey(generics.ListAPIView): 'error': str(error) }) + +def GetSummaryHtml(request, sas_id): + """ + Construct and return a summary html structure for given sas_id + This is the same informtion and algorithm as used when the user clicks the SUM button on the Validation page. + See documentation: https://drive.google.com/file/d/16R8L06OFiKHFHBUA6FhrNVZVAaQBC2tU/view?usp=sharing + + example: /atdb/get_summary_html/606942 + """ + try: + + # use a trick to be able to use the existing task based code + queryset = Task.objects.filter(sas_id=sas_id) + task = queryset[0] + + # add some basic layout without using the summary.html template + head_html=""" + <head> + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> + <link href='https://fonts.googleapis.com/css?family=Raleway' rel='stylesheet' type='text/css'> + </head> + """ + + body_html = """ + <html> + <body> + <div class="container-fluid details-container"> + <div class='card'><table> + <div class="card-body"> + <table class="table table-striped"> + """ + + # create the core html + summary_html = algorithms.construct_summary(task) + + # close all the tags + footer_html = "</table></div></div></div></body></html>" + + # combine the html sections + html = head_html + body_html + summary_html + footer_html + + return HttpResponse(html) + + except Exception as error: + logger.error(error) + return JsonResponse({ + 'error': str(error) + }) + + +def GetSummaryJson(request, sas_id): + """ + Construct and return a summary json structure for given sas_id + This is the same informtion and algorithm as used when the user clicks the SUM button on the Validation page. + See documentation: https://drive.google.com/file/d/16R8L06OFiKHFHBUA6FhrNVZVAaQBC2tU/view?usp=sharing + + example: /atdb/get_summary_json/606942 + """ + try: + + # use a trick to be able to use the existing task based code + queryset = Task.objects.filter(sas_id=sas_id) + task = queryset[0] + #summary_json = algorithms.construct_summary_json(task) + summary_json = None + return JsonResponse({ + 'summary': summary_json + }) + + + except Exception as error: + logger.error(error) + return JsonResponse({ + 'error': str(error) + }) + + + @staff_member_required def AssociateActivities(request): # disconnect the signals to avoid unneccesary updates