From 407f15965d50ace158e9f283c307a8c4b280c7f4 Mon Sep 17 00:00:00 2001 From: luissian Date: Sun, 29 Sep 2024 23:58:17 +0200 Subject: [PATCH] Solved issue #325 Unable to create protocol parameters if it is not done just after creation --- core/utils/protocols.py | 2 +- wetlab/templates/wetlab/create_protocol.html | 2 +- wetlab/views.py | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/core/utils/protocols.py b/core/utils/protocols.py index eb2af48bd..8d9a0c72c 100644 --- a/core/utils/protocols.py +++ b/core/utils/protocols.py @@ -176,7 +176,6 @@ def get_all_protocol_info(protocol_id): protocol_data. """ protocol_data = {} - protocol_data["parameters"] = [] protocol_obj = core.models.Protocols.objects.get(pk__exact=protocol_id) if core.models.ProtocolParameters.objects.filter(protocol_id=protocol_obj).exists(): @@ -187,6 +186,7 @@ def get_all_protocol_info(protocol_id): protocol_parameters = core.models.ProtocolParameters.objects.filter( protocol_id=protocol_obj ).order_by("parameter_order") + protocol_data["parameters"] = [] for parameter in protocol_parameters: protocol_data["parameters"].append(parameter.get_all_parameter_info()) protocol_data["protocol_id"] = protocol_id diff --git a/wetlab/templates/wetlab/create_protocol.html b/wetlab/templates/wetlab/create_protocol.html index 2afa95d7a..99d7d88be 100644 --- a/wetlab/templates/wetlab/create_protocol.html +++ b/wetlab/templates/wetlab/create_protocol.html @@ -93,7 +93,7 @@

{{ERROR}}

-

Protocols already defined for Molecules

+

Protocols already defined

{% if defined_protocols %} diff --git a/wetlab/views.py b/wetlab/views.py index 0376c1d1c..2126d60f5 100644 --- a/wetlab/views.py +++ b/wetlab/views.py @@ -14,6 +14,7 @@ from django.contrib.auth.decorators import login_required from django.core.files.storage import FileSystemStorage from django.shortcuts import redirect, render +from django.urls import reverse # Local imports # import core.fusioncharts.fusioncharts @@ -1988,6 +1989,11 @@ def display_protocol(request, protocol_id): }, ) protocol_data = core.utils.protocols.get_all_protocol_info(protocol_id) + # if there are no parameters defined for the protocol, + # redirect to define_protocol_parameters + if len(protocol_data) == 0: + url = reverse("define_protocol_parameters", kwargs={"protocol_id": protocol_id}) + return redirect(url) kit_data = wetlab.utils.additional_kits.get_all_additional_kit_info(protocol_id) return render(