Skip to content

Commit

Permalink
solved issue BU-ISCIII#319 incorrect state set for molecule after fil…
Browse files Browse the repository at this point in the history
…ling the extraction data
  • Loading branch information
luissian committed Sep 27, 2024
1 parent 0df6259 commit 8abc1dc
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 24 deletions.
17 changes: 14 additions & 3 deletions conf/first_install_tables.json
Original file line number Diff line number Diff line change
Expand Up @@ -324,21 +324,32 @@
"model": "core.statesformolecule",
"pk": 3,
"fields": {
"molecule_state_name": "Defined"
"molecule_state_name": "defined",
"molecule_state_display": "Defined"
}
},
{
"model": "core.statesformolecule",
"pk": 4,
"fields": {
"molecule_state_name": "Assigned Protocol"
"molecule_state_name": "assigned_parameters",
"molecule_state_display": "Assigned Parameters"
}
},
{
"model": "core.statesformolecule",
"pk": 5,
"fields": {
"molecule_state_name": "Completed"
"molecule_state_name": "completed",
"molecule_state_display": "Completed"
}
},
{
"model": "core.statesformolecule",
"pk": 6,
"fields": {
"molecule_state_name": "sent_external",
"molecule_state_display": "Sent to external service"
}
},
{
Expand Down
6 changes: 3 additions & 3 deletions core/core_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
]
HEADING_FOR_MOLECULE_ADDING_PARAMETERS = [
"Sample",
"Molecule Code ID",
"Extraction Code ID",
"Lot Commercial Kit",
]

Expand Down Expand Up @@ -74,8 +74,8 @@

HEADING_FOR_SELECTING_MOLECULE_USE = [
"Sample Name",
"Molecule CodeID",
"Molecule use for",
"Extraction CodeID",
"Sample continue on",
]

# ################ PROTOCOL PARAMETER SETTINGS ##############################
Expand Down
3 changes: 2 additions & 1 deletion core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ def get_id(self):

class StatesForMolecule(models.Model):
molecule_state_name = models.CharField(max_length=50)
molecule_state_display = models.CharField(max_length=80, null=True, blank=True)

class Meta:
db_table = "core_states_for_molecule"
Expand Down Expand Up @@ -1495,7 +1496,7 @@ def create_molecule(self, molecule_data):
protocol_used=protocol_used_obj,
sample=molecule_data["sample"],
molecule_type=molecule_used_obj,
state=StatesForMolecule.objects.get(molecule_state_name__exact="Defined"),
state=StatesForMolecule.objects.get(molecule_state_name__exact="defined"),
molecule_code_id=molecule_data["molecule_code_id"],
molecule_extraction_date=molecule_data["molecule_extraction_date"],
extraction_type=molecule_data["extraction_type"],
Expand Down
10 changes: 5 additions & 5 deletions core/utils/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ def add_molecule_protocol_parameters(data, parameters):
molecule_parameter_value
)

molecule_obj.set_state("Completed")
molecule_obj.set_state("assigned_parameters")
# Update sample state
sample_obj = molecule_obj.get_sample_obj()
sample_obj.set_state("Pending for use")
Expand Down Expand Up @@ -701,10 +701,10 @@ def create_table_molecule_pending_use(sample_list, app_name):
use_type = {}
use_type["data"] = list(
core.models.MoleculePreparation.objects.filter(
molecule_used_for=None, sample__in=sample_list
)
.exclude(state__molecule_state_name="Completed")
.values_list("sample__sample_name", "molecule_code_id", "pk")
molecule_used_for=None,
sample__in=sample_list,
state__molecule_state_name="assigned_parameters",
).values_list("sample__sample_name", "molecule_code_id", "pk")
)
if len(use_type["data"]) > 0:
if core.models.MoleculeUsedFor.objects.filter(
Expand Down
22 changes: 11 additions & 11 deletions wetlab/templates/wetlab/handling_molecules.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ <h3>Information missing</h3>
<div class="col-md">
<div class="card ">
<div class="card-header">
<h3>Update molecules data with defined parameters</h3>
<h3>Update sample extraction data with defined parameters</h3>
</div>
<div class="card-body">
<form method="post"
enctype="multipart/form-data"
name="addMoleculeParameters"
id="addMoleculeParameters">
name="addExtractionParameters"
id="addExtractionParameters">
{% csrf_token %}
<input type="hidden" name="action" value="addMoleculeParameters" />
<input type="hidden" name="action" value="addExtractionParameters" />
<input type="hidden" name="protocol_list" value="{{ protocol_list }}" />
{% for prot, value_dict in molecule_parameters.items %}
<input type="hidden"
Expand Down Expand Up @@ -147,13 +147,13 @@ <h5>Protocol: {{ prot }}</h5>
<div class="col-sm-12">
<div class="card ">
<div class="card-header text-center">
<h3>Molecules have been updated with required parameters.</h3>
<h3>Samples have been updated with Extraction required parameters.</h3>
</div>
<div class="row my-3 justify-content-center">
<div class="col-md-3">
<input type="button"
class="btn btn-outline-secondary"
value="Return to handling molecules"
value="Return to handling extraction samples"
onclick="location.href ='/wetlab/handlingMolecules' ;" />
</div>
</div>
Expand Down Expand Up @@ -208,7 +208,7 @@ <h3>Molecules are updated with their use.</h3>
type="button"
role="tab"
aria-controls="n_samples"
aria-selected="true">New Samples</button>
aria-selected="true">Recorded Samples</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link"
Expand All @@ -218,7 +218,7 @@ <h3>Molecules are updated with their use.</h3>
type="button"
role="tab"
aria-controls="molecule"
aria-selected="false">Pending molecules</button>
aria-selected="false">Pending Extraction data</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link"
Expand All @@ -228,7 +228,7 @@ <h3>Molecules are updated with their use.</h3>
type="button"
role="tab"
aria-controls="mol_use"
aria-selected="false">Molecules use specification</button>
aria-selected="false">Next action after extraction</button>
</li>
</ul>
<div class="tab-content bg-white border-tab p-2" id="nav-tabContent">
Expand Down Expand Up @@ -669,13 +669,13 @@ <h4>Not molecule uses have been defined yet</h4>
});


$("#addMoleculeParameters").submit(function (e) {
$("#addExtractionParameters").submit(function (e) {
var table_data = {{ prot }}_data_table.getData()
var data_json = JSON.stringify(table_data)
$("<input />").attr("type", "hidden")
.attr("name", "{{ prot }}")
.attr("value", data_json)
.appendTo("#addMoleculeParameters");
.appendTo("#addExtractionParameters");
$("#button-submit").attr("disabled", true);
return true;
});
Expand Down
3 changes: 2 additions & 1 deletion wetlab/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3303,7 +3303,7 @@ def handling_molecules(request):
},
)

elif request.method == "POST" and request.POST["action"] == "addMoleculeParameters":
elif request.method == "POST" and request.POST["action"] == "addExtractionParameters":
protocols = request.POST["protocol_list"].split(";")
for protocol in protocols:
heading = core.core_config.HEADING_FOR_MOLECULE_ADDING_PARAMETERS.copy()
Expand Down Expand Up @@ -3371,6 +3371,7 @@ def handling_molecules(request):
molecule_use_defined = core.utils.samples.check_if_molecule_use_defined(
__package__
)

return render(
request,
"wetlab/handling_molecules.html",
Expand Down

0 comments on commit 8abc1dc

Please sign in to comment.