Skip to content

Commit

Permalink
Merge pull request #235 from darkreactions/nicole_03-28
Browse files Browse the repository at this point in the history
add concentrations to reagent prep view
  • Loading branch information
nsmina914 authored Mar 28, 2022
2 parents 82297ab + b992962 commit 9ee0033
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 30 deletions.
41 changes: 20 additions & 21 deletions escalate/core/forms/custom_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ def get_helper():
helper.label_class = "col-lg-2"
helper.field_class = "col-lg-8"
helper.layout = Layout(
Row(Column(Field("file"))),
Row(Column(Submit("robot_upload", "Submit"))),
Row(Column(Field("file"))), Row(Column(Submit("robot_upload", "Submit"))),
)
return helper

Expand All @@ -58,9 +57,7 @@ def get_helper():
helper.form_class = "form-horizontal"
helper.label_class = "col-lg-2"
helper.field_class = "col-lg-8"
helper.layout = Layout(
Row(Column(Field("file"))),
)
helper.layout = Layout(Row(Column(Field("file"))),)
helper.form_tag = False
return helper

Expand Down Expand Up @@ -136,9 +133,7 @@ class ReagentTemplateCreateForm(Form):
reagent_template_name = CharField(label="Reagent Name", required=True)

select_mt = MultipleChoiceField(
widget=SelectMultiple(),
required=True,
label="Select Material Types",
widget=SelectMultiple(), required=True, label="Select Material Types",
)

def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -463,10 +458,7 @@ def get_helper():
helper.label_class = "col-lg-3"
helper.field_class = "col-lg-8"
helper.layout = Layout(
Row(
Column(Field("chemical")),
Column(Field("desired_concentration")),
),
Row(Column(Field("chemical")), Column(Field("desired_concentration")),),
Field("reagent_template_uuid"),
Field("material_type"),
)
Expand All @@ -476,6 +468,7 @@ def get_helper():
class ReagentValueForm(Form):
material_type = CharField(required=False)
material = CharField(required=False)
concentration = ValFormField(required=False)
nominal_value = ValFormField(required=False)
actual_value = ValFormField()
uuid = CharField(widget=HiddenInput())
Expand Down Expand Up @@ -516,10 +509,21 @@ def is_readonly(field):
),
),
Row(
Column(Field("nominal_value", readonly=is_readonly("nominal_value"))),
Column(Field("actual_value")),
Column(
Field(
"concentration",
readonly=is_readonly("concentration"),
# css_class="form-control-plaintext",
)
),
Row(
Column(
Field("nominal_value", readonly=is_readonly("nominal_value"))
),
Column(Field("actual_value")),
),
Row("uuid"),
),
Row("uuid"),
)
return helper

Expand Down Expand Up @@ -557,12 +561,7 @@ def get_helper():
helper.form_class = "form-horizontal"
helper.label_class = "col-lg-3"
helper.field_class = "col-lg-8"
helper.layout = Layout(
Row(
Column(Field("actual_value")),
Row(Field("file")),
),
)
helper.layout = Layout(Row(Column(Field("actual_value")), Row(Field("file")),),)
return helper

class Meta:
Expand Down
31 changes: 22 additions & 9 deletions escalate/core/views/experiment/prep_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ class ExperimentReagentPrepView(TemplateView):
# form_class = ExperimentTemplateForm
# ReagentFormSet = formset_factory(ReagentForm, extra=0, formset=BaseReagentFormSet)
ReagentFormSet = formset_factory(
ReagentValueForm,
extra=0,
formset=BaseReagentFormSet,
ReagentValueForm, extra=0, formset=BaseReagentFormSet,
)

def get(self, request, *args, **kwargs):
Expand Down Expand Up @@ -56,11 +54,21 @@ def get_reagent_forms(self, experiment, context):
reagent_template_names = []
reagent_total_volume_forms = []
form_kwargs = {
"disabled_fields": ["material", "material_type", "nominal_value"],
"disabled_fields": [
"material",
"material_type",
"concentration",
"nominal_value",
],
}

context["helper"] = ReagentValueForm.get_helper(
readonly_fields=["material", "material_type", "nominal_value"]
readonly_fields=[
"material",
"material_type",
"concentration",
"nominal_value",
]
)
context["helper"].form_tag = False

Expand Down Expand Up @@ -90,16 +98,21 @@ def get_reagent_forms(self, experiment, context):
for reagent_material in reagent_materials:

reagent_names.append(reagent_material.description)
rmvi = reagent_material.property_rm.all().get(
rmvi_amount = reagent_material.property_rm.all().get(
template__description="amount"
)
rmvi_conc = reagent_material.property_rm.all().get(
template__description="concentration"
)

initial.append(
{
"material_type": reagent_material.template.material_type.description,
"material": reagent_material.material,
"nominal_value": rmvi.nominal_value,
"actual_value": rmvi.value,
"uuid": rmvi.uuid,
"concentration": rmvi_conc.nominal_value,
"nominal_value": rmvi_amount.nominal_value,
"actual_value": rmvi_amount.value,
"uuid": rmvi_amount.uuid,
}
)

Expand Down

0 comments on commit 9ee0033

Please sign in to comment.