Skip to content

Commit

Permalink
solved issue BU-ISCIII#300 Error when sample proyects has no parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
luissian committed Sep 28, 2024
1 parent b0a03a5 commit 2c98ce2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: 3.9.x
architecture: x64
Expand Down
11 changes: 8 additions & 3 deletions core/utils/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,18 @@ def save_recorded_samples(samples_data, req_user, app_name):
sample["sample_project"] = core.models.SampleProjects.objects.get(
sample_project_name__exact=sample["sample_project"]
)

# If only recorded set sample to completed state
if sample["only_recorded"] and sample["sample_project"] is None:
sample["sample_state"] = "Completed"
sample["completed_date"] = datetime.datetime.now()
# If no sample project data needed set to defined
elif sample["sample_project"] is None:
# If no sample project data needed or sample projects has no parameters
# then set the sample state to defined
elif (
sample["sample_project"] is None
or core.models.SampleProjects.objects.filter(
sample_project_name__exact=sample["sample_project"]
).exists()
):
sample["sample_state"] = "Defined"
else:
sample["sample_state"] = "Pre-Defined"
Expand Down
8 changes: 7 additions & 1 deletion wetlab/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2225,7 +2225,13 @@ def record_samples(request):
sample["sample_project"] not in project_ids
and sample["sample_project"] is not None
):
project_ids.append(sample["sample_project"])
# check if sample project has defined parameters
if core.models.SampleProjectsFields.objects.filter(
sample_projects_id__sample_project_name__exact=sample[
"sample_project"
]
).exists():
project_ids.append(sample["sample_project"])
# If no sample Pre-Defined just show result
if not project_ids:
return render(
Expand Down

0 comments on commit 2c98ce2

Please sign in to comment.