diff --git a/atdb/taskdatabase/services/algorithms.py b/atdb/taskdatabase/services/algorithms.py index 62fe1b7ba12196b4e00d31f296496ebbf1805db9..eb0a0d4579cf06624aab550489ea092d78035b9a 100644 --- a/atdb/taskdatabase/services/algorithms.py +++ b/atdb/taskdatabase/services/algorithms.py @@ -287,9 +287,9 @@ def convert_monitor_to_html(request, monitor_data): # only provide the hold/resume buttons for superusers, otherwise just show the state if request.user.is_superuser: if record.enabled=="True": - service_enabled = str(record.enabled) + ' <a href="service_hold_resume/' + str(record.pk) + '/False"' + 'class="btn btn-warning btn-sm" role="button"><i class="fas fa-pause"></i> Hold</a>' + service_enabled = str(record.enabled) + ' <a href="service_hold_resume/' + record.name + '/' + record.hostname + '/False"' + 'class="btn btn-warning btn-sm" role="button"><i class="fas fa-pause"></i> Hold</a>' else: - service_enabled = str(record.enabled) + ' <a href="service_hold_resume/' + str(record.pk) + '/True"' + 'class="btn btn-success btn-sm" role="button"><i class="fas fa-play"></i> Resume</a>' + service_enabled = str(record.enabled) + ' <a href="service_hold_resume/' + record.name + '/' + record.hostname + '/True"' + 'class="btn btn-success btn-sm" role="button"><i class="fas fa-play"></i> Resume</a>' else: service_enabled = str(record.enabled) diff --git a/atdb/taskdatabase/urls.py b/atdb/taskdatabase/urls.py index e55c0c0335c99b9232cddff67cd81f3287ef90ad..4c2fb8dbb00d45d9e90259815e134f22eeea0b9d 100644 --- a/atdb/taskdatabase/urls.py +++ b/atdb/taskdatabase/urls.py @@ -72,7 +72,8 @@ urlpatterns = [ path('monitor/<int:pk>/', views.MonitorDetailsViewAPI.as_view(),name='monitor-detail-view-api'), path('latest_monitor/', views.LatestMonitorListViewAPI.as_view(),name='latest-monitor-detail-view-api'), path('monitor/clear_inactive_services/', views.ClearInactiveServices, name='clear-inactive-services'), - path('monitoring/service_hold_resume/<int:pk>/<enabled>', views.ServiceHoldResume, name='service-hold-resume'), + # path('monitoring/service_hold_resume/<int:pk>/<enabled>', views.ServiceHoldResume, name='service-hold-resume'), + path('monitoring/service_hold_resume/<name>/<hostname>/<enabled>', views.ServiceHoldResume, name='service-hold-resume'), # --- custom requests --- # /atdb/get_size?status__in=defined,staged diff --git a/atdb/taskdatabase/views.py b/atdb/taskdatabase/views.py index f6775feb55ce896ef2825ff784c385ea40897c7e..02b3fbf617b5cf61e0d7bcef8caf41743a380f33 100644 --- a/atdb/taskdatabase/views.py +++ b/atdb/taskdatabase/views.py @@ -953,9 +953,9 @@ def HoldQuery(request, pk, hold_it, query_params): return redirect('/atdb/query/?' + current_query_params) @login_required -def ServiceHoldResume(request, pk, enabled): +def ServiceHoldResume(request, name, hostname, enabled): model = LatestMonitor - service = LatestMonitor.objects.get(pk=pk) + service = LatestMonitor.objects.get(name=name,hostname=hostname) metadata = service.metadata if not metadata: metadata = {}