Skip to content

Commit

Permalink
Solved issue BU-ISCIII#325 Unable to create protocol parameters if it…
Browse files Browse the repository at this point in the history
… is not done just after creation
  • Loading branch information
luissian committed Sep 29, 2024
1 parent c1de43b commit 407f159
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/utils/protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion wetlab/templates/wetlab/create_protocol.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ <h4>{{ERROR}}</h4>
<div class="container">
<div class="row mt-4">
<div class="card ">
<div class="card-header"><h3 style="text-align-center">Protocols already defined for Molecules</h3></div>
<div class="card-header"><h3 style="text-align-center">Protocols already defined</h3></div>
<div class="card-body">
{% if defined_protocols %}
<table class="table table-hover" id="prot_table">
Expand Down
6 changes: 6 additions & 0 deletions wetlab/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 407f159

Please sign in to comment.