Skip to content

Commit

Permalink
Solved issue BU-ISCIII#324 Unable to specify downloadable parameters …
Browse files Browse the repository at this point in the history
…in protocol
  • Loading branch information
luissian committed Sep 29, 2024
1 parent c748ec0 commit c1de43b
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 50 deletions.
4 changes: 4 additions & 0 deletions core/core_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"Parameter name",
"Order",
"Used",
"Downloadable",
"Parameter Type",
"Option Values",
"Min Value",
Expand All @@ -95,8 +96,11 @@
"New field name",
"Order",
"Used",
"Downloadable",
"Parameter Type",
"Option Values",
"Min Value",
"Max Value",
"Description",
]

Expand Down
22 changes: 17 additions & 5 deletions core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ def create_protocol_parameter(self, prot_param_data):
parameter_min_value=prot_param_data["Min Value"],
parameter_option_values=prot_param_data["Option Values"],
parameter_type=prot_param_data["Parameter Type"],
parameter_download=prot_param_data["Downloadable"],
)
return new_prot_parameter

Expand All @@ -292,6 +293,7 @@ class ProtocolParameters(models.Model):
parameter_option_values = models.CharField(max_length=400, null=True, blank=True)
parameter_max_value = models.CharField(max_length=50, null=True, blank=True)
parameter_min_value = models.CharField(max_length=50, null=True, blank=True)
parameter_download = models.BooleanField(default=False, null=True, blank=True)

class Meta:
db_table = "core_protocol_parameters"
Expand All @@ -316,6 +318,7 @@ def get_all_parameter_info(self):
param_info.append(self.parameter_name)
param_info.append(self.parameter_order)
param_info.append(self.parameter_used)
param_info.append(self.parameter_download)
param_info.append(self.parameter_type)
param_info.append(self.parameter_option_values)
param_info.append(self.parameter_min_value)
Expand All @@ -328,17 +331,23 @@ def get_protocol_fields_for_javascript(self):
used = "true"
else:
used = "false"
if self.parameter_download:
download = "true"
else:
download = "false"
if self.parameter_option_values is None:
parameter_option_values = ""
else:
parameter_option_values = self.parameter_option_values
field_data = []
field_data.append(self.parameter_name)

field_data.append(self.parameter_order)
field_data.append(used)
field_data.append(download)
field_data.append(self.parameter_type)
field_data.append(parameter_option_values)
field_data.append(self.parameter_min_value)
field_data.append(self.parameter_max_value)
field_data.append(self.parameter_description)
return field_data

Expand All @@ -347,8 +356,11 @@ def update_protocol_fields(self, prot_param_data):
self.parameter_description = prot_param_data["Description"]
self.parameter_order = prot_param_data["Order"]
self.parameter_used = prot_param_data["Used"]
self.parameter_download = prot_param_data["Downloadable"]
self.parameter_option_values = prot_param_data["Option Values"]
self.parameter_type = prot_param_data["Parameter Type"]
self.parameter_max_value = prot_param_data["Max Value"]
self.parameter_min_value = prot_param_data["Min Value"]
self.save()

objects = ProtocolParametersManager()
Expand Down Expand Up @@ -929,7 +941,7 @@ def create_sample_project_fields(self, project_field_data):
sample_project_field_order=project_field_data["Order"],
sample_project_field_used=project_field_data["Used"],
sample_project_field_type=project_field_data["Field type"],
sample_project_searchable=project_field_data["Searchable"],
sample_project_downloadable=project_field_data["Downloadable"],
# do not include optional values. Set to empty
sample_project_option_list="",
)
Expand Down Expand Up @@ -958,7 +970,7 @@ class SampleProjectsFields(models.Model):
sample_project_field_used = models.BooleanField()
sample_project_field_type = models.CharField(max_length=20)
sample_project_option_list = models.CharField(max_length=255, null=True, blank=True)
sample_project_searchable = models.BooleanField(default=False)
sample_project_downloadable = models.BooleanField(default=False)
generated_at = models.DateTimeField(auto_now_add=True)

class Meta:
Expand Down Expand Up @@ -1006,7 +1018,7 @@ def get_sample_project_fields_name(self, include_search=None):
used = "true"
else:
used = "false"
if self.sample_project_searchable:
if self.sample_project_downloadable:
searchable = "true"
else:
searchable = "false"
Expand Down Expand Up @@ -1036,7 +1048,7 @@ def update_sample_project_fields(self, project_field_data):
self.sample_project_field_order = project_field_data["Order"]
self.sample_project_field_used = project_field_data["Used"]
self.sample_project_field_type = project_field_data["Field type"]
self.sample_project_searchable = project_field_data["Searchable"]
self.sample_project_downloadable = project_field_data["Downloadable"]
self.sample_project_field_classification_id = project_field_data[
"SampleProjectFieldClassificationID"
]
Expand Down
4 changes: 1 addition & 3 deletions core/utils/protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ def get_protocol_fields(protocol_id):
parameters_protocol["protocol_id"] = protocol_id
parameters_protocol["protocol_name"] = protocol_obj.get_name()
parameters_protocol["fields"] = parameter_list

return parameters_protocol


Expand Down Expand Up @@ -365,13 +364,12 @@ def modify_fields_in_protocol(form_data):

def set_protocol_parameters(request):
protocol_id = request.POST["protocol_id"]
json_data = json.loads(request.POST["table_data1"])
parameters = core.core_config.HEADING_FOR_DEFINING_PROTOCOL_PARAMETERS
protocol_id_obj = core.models.Protocols.objects.get(pk__exact=protocol_id)

saved_parameters = []
stored_parameters = {}
for row_data in json_data:
for row_data in json.loads(request.POST["table_data1"]):
if row_data[0] == "":
continue
prot_parameters = {}
Expand Down
3 changes: 0 additions & 3 deletions core/utils/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -2113,9 +2113,6 @@ def set_sample_project_fields(data_form):
saved_fields = []
stored_fields = {}
valid_data = False
import pdb

pdb.set_trace()
# check if there is at least one field to be used
for row_line in excel_json_data:
if row_line["Used"] is True:
Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ if [ $upgrade == true ]; then
echo "Running migration script: remove_comma_rawtopunknownbarcodes"
./manage.py runscript convert_rawtop_counter_to_int
echo "checking for database changes"
if python manage.py makemigrations | grep -q "No changes"; then
if python manage.py makemigrations --noinput | grep -q "No changes"; then
# check for pending migrations
if ./manage.py showmigrations | grep '\[ \]'; then
echo "There are pending migrations"
Expand Down
24 changes: 13 additions & 11 deletions wetlab/templates/wetlab/define_protocol_parameters.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="row mt-2 mb-4">
<div class="col-md-7 offset-3">
<div class="card border-danger mb-3">
<div class="card-header border-danger text-center"><h3>Invalid definition </h3le=> </div>
<div class="card-header border-danger text-center"><h3>Invalid definition </h3> </div>
<div class="card-body">
<h4>{{error_message}}</h4>
</div>
Expand Down Expand Up @@ -56,10 +56,11 @@ <h4>{{error_message}}</h4>
<input type="hidden" name="action" value="define_protocol_parameters"/>
<input type="hidden" name="protocol_id" value="{{prot_parameters.protocol_id}}"/>
<h4>Define the parameters used for protocol {{prot_parameters.protocol_name}}</h4>
<div id="spreadsheet1"></div>

<input type="button" class="btn btn-outline-secondary" value="Download_Protocol_Parameters" onclick="table1.download()"/>
<input class="btn float-end btn-outline-primary" type="submit" value="Submit">
<div class="row mt-4 horizontal-scroll">
<div id="spreadsheet1" class="mb-3"></div>
</div>
<input type="button" class="btn btn-outline-secondary mt-3" value="Download_Protocol_Parameters" onclick="table1.download()"/>
<input class="btn float-end btn-outline-primary mt-3" type="submit" value="Submit">
</form>
</div>
<script>
Expand All @@ -72,17 +73,18 @@ <h4>Define the parameters used for protocol {{prot_parameters.protocol_name}}</h
{ type: 'text', title:'{{prot_parameters.heading.0}}', width:160 },
{ type: 'numeric', title:'{{prot_parameters.heading.1}}', width:50, mask:' #.##' },
{ type: 'checkbox', title:'{{prot_parameters.heading.2}}', width:50 },
{ type: 'dropdown' , title: '{{prot_parameters.heading.3}}', width:140 , source: ["string", "Date" , "Option List"] },
{ type: 'text' , title: '{{prot_parameters.heading.4}}', width:240, wordWrap:true},
{ type: 'text' , title: '{{prot_parameters.heading.5}}', width:90 },
{ type: 'text', title:'{{prot_parameters.heading.6}}', width:90 },
{ type: 'text', title:'{{prot_parameters.heading.7}}', width:300 , wordWrap:true },
{ type: 'checkbox', title:'{{prot_parameters.heading.3}}', width:100 },
{ type: 'dropdown' , title: '{{prot_parameters.heading.4}}', width:140 , source: ["string", "Date" , "Option List"] },
{ type: 'text' , title: '{{prot_parameters.heading.5}}', width:240, wordWrap:true},
{ type: 'text' , title: '{{prot_parameters.heading.6}}', width:90 },
{ type: 'text', title:'{{prot_parameters.heading.7}}', width:90 },
{ type: 'text', title:'{{prot_parameters.heading.8}}', width:300 , wordWrap:true },
],
allowInsertColumn:false,
allowDeleteColumn:false,
allowRenameColumn:false,
csvFileName:'protocol_parameters',
minDimensions:[6,3],
minDimensions:[9,5],
});
// Function to check if at least one checkbox in the "Used" column is set to true
function isAnyUsedColumnChecked() {
Expand Down
44 changes: 27 additions & 17 deletions wetlab/templates/wetlab/display_protocol.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,35 @@ <h3>Parameters defined for {{protocol_data.protocol_name}} Protocol</h3>
<div class="card ">
<div class="card-header"><h4>{{protocol_data.protocol_name}}</h4></div>
<div class="card-body">
<div class="col-sm-11" >
<table class="table table-hover">
<thead>
<tr>
{% for value in protocol_data.parameter_heading %}
<th>{{value}}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for values in protocol_data.parameters %}
<div class="row mt-2 horizontal-scroll">
<div class="col-sm-11" >
<table class="table table-hover">
<thead>
<tr>
{% for value in values %}
<td>{{ value }}</td>
{% endfor %}
{% for value in protocol_data.parameter_heading %}
<th>{{value}}</th>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</thead>
<tbody>
{% for values in protocol_data.parameters %}
<tr>
{% for value in values %}
<td>
{% if value == 'Yes' or value == True %}
<i class="bi bi-check2-circle" style="font-size:20px;color:green"></i>
{% elif value == 'No' or value == False %}
<i class="bi bi-stop-circle" style="font-size:20px;color:red"></i>
{% else %}
{{ value }}
{% endif %}
</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<input class="btn btn-outline-primary float-end my-3" type="submit" value="Modify Protocol Fields" onclick="window.location.href = '/wetlab/modifyProtocolFields={{protocol_data.protocol_id}}';">
</div>
Expand Down
18 changes: 15 additions & 3 deletions wetlab/templates/wetlab/display_sample_project.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,24 @@ <h3>Fields definition</h3>
</tr>
</thead>
<tbody>
{% for name, order, used, search, type, option, descrp, classif in samples_project_data.fields %}
{% for name, order, used, download, type, option, descrp, classif in samples_project_data.fields %}
<tr>
<td>{{ name }}</td>
<td>{{ order }}</td>
<td>{{ used }}</td>
<td>{{ search }}</td>
<td>
{% if used == 'Yes' or used == "true" %}
<i class="bi bi-check2-circle" style="font-size:20px;color:green"></i>
{% else %}
<i class="bi bi-stop-circle" style="font-size:20px;color:red"></i>
{% endif %}
</td>
<td>
{% if download == 'Yes' or download == "true" %}
<i class="bi bi-check2-circle" style="font-size:20px;color:green"></i>
{% else %}
<i class="bi bi-stop-circle" style="font-size:20px;color:red"></i>
{% endif %}
</td>
<td>{{ type }}</td>
<td>
{% if option != "" %}<a href="#" data-toggle="tooltip" title="{{ option }}">See options</a>{% endif %}
Expand Down
Loading

0 comments on commit c1de43b

Please sign in to comment.