From 38888f31f126da2fdb774b418440dcf13daeed9c Mon Sep 17 00:00:00 2001 From: rutvikrj26 Date: Thu, 23 Nov 2023 10:27:02 -0500 Subject: [PATCH] Issue with double request --- .../templates/events/event_applications.html | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/physionet-django/events/templates/events/event_applications.html b/physionet-django/events/templates/events/event_applications.html index b2431be639..2163da9688 100644 --- a/physionet-django/events/templates/events/event_applications.html +++ b/physionet-django/events/templates/events/event_applications.html @@ -68,13 +68,19 @@ $form.find('input[type="submit"]').prop('disabled', false); - if ($form.attr('data-action') == 'MAKE_COHOST') { - $form.attr('data-action', 'REMOVE_COHOST'); + current_action = $form.find('input[type="submit"]').attr('data-action'); + make_cohost_action = '{{ cohostStatus.MAKE_COHOST }}'; + remove_cohost_action = '{{ cohostStatus.REMOVE_COHOST }}'; + + console.log(current_action, make_cohost_action, remove_cohost_action); + + if (current_action == make_cohost_action) { + $form.find('input[type="submit"]').attr('data-action', remove_cohost_action); $form.find('input[type="submit"]').val('Remove cohost'); $form.find('input[type="submit"]').removeClass('btn-primary'); $form.find('input[type="submit"]').addClass('btn-danger'); - } else if ($form.attr('data-action') == 'REMOVE_COHOST') { - $form.attr('data-action', 'MAKE_COHOST'); + } else if (current_action == remove_cohost_action) { + $form.find('input[type="submit"]').attr('data-action', make_cohost_action); $form.find('input[type="submit"]').val('Make cohost'); $form.find('input[type="submit"]').removeClass('btn-danger'); $form.find('input[type="submit"]').addClass('btn-success');