Skip to content

Commit

Permalink
* Add additional info
Browse files Browse the repository at this point in the history
* Add shading to table
* Add Dynamic type checking to header table
* Use correct row for Design w/cm
  • Loading branch information
luthando5 committed Jan 9, 2025
1 parent 2a8e0f0 commit 39b5f62
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 54 deletions.
62 changes: 18 additions & 44 deletions src/bika/cement/browser/batch/templates/mix_mortar_paste_view.pt
Original file line number Diff line number Diff line change
Expand Up @@ -22,54 +22,28 @@

<div metal:fill-slot="content-core" tal:define="mix_design python:view.get_mix_design()">
<div class="col-12">
<table class="table table-sm table-condensed">
<table class="table table-sm table-bordered">
<colgroup>
<col style="width:50%"/>
<col style="width:50%"/>
<col style="width:25%"/>
<col style="width:25%"/>
<col style="width:25%"/>
<col style="width:25%"/>
</colgroup>
<tr>
<td style="border:none;" class="align-top pr-2">
<!-- Left Table -->
<table class="table table-sm table-condensed">
<!-- Client Name(s) -->
<tr>
<td class="label" i18n:translate="">Project</td>
<td class="field">
<div tal:content="mix_design/project"/>
</td>
</tr>
<!-- Contact Name(s) -->
<tr>
<td class="label" i18n:translate="">Date</td>
<td class="field">
<div tal:content="mix_design/date"/>
</td>
</tr>
</table>
</td>
<td style="border:none;" class="align-top pl-2">
<!-- Right Table -->
<table class="table table-sm table-condensed">
<!-- Client Name(s) -->
<tr>
<td class="label" i18n:translate="">Design</td>
<td class="field">
<div tal:content="mix_design/title"/>
</td>
</tr>
<!-- Contact Name(s) -->
<tr>
<td class="label" i18n:translate="">Type</td>
<td class="field">
<div>Mortar</div>
</td>
</tr>
</table>
</td>
<td class="label bg-light" i18n:translate="">Project</td>
<td class="field"><div tal:content="mix_design/project|nothing"/></td>
<td class="label bg-light" i18n:translate="">Design</td>
<td class="field"><div tal:content="mix_design/title|nothing"/></td>
</tr>
<!-- Contact Name(s) -->
<tr>
<td class="label bg-light" i18n:translate="">Date</td>
<td class="field"><div tal:content="mix_design/date|nothing"/></td>
<td class="label bg-light" i18n:translate="">Type</td>
<td class="field"><div tal:content="mix_design/get_mix_design_type|nothing"/></td>
</tr>
</table>
</div>
<!-- -->

<div class="col-12" tal:define="concrete python:view.get_mix_design_mortar_paste()">
<table class="sampleheader-table table table-sm table-bordered">
Expand Down Expand Up @@ -99,13 +73,13 @@
<div class="col-12" id="sample-sections">
<div tal:replace="structure provider:senaite.samplesections"></div>
</div>
<div class="col-12" tal:define="concrete python:view.get_mix_design_mortar_paste()">
<div class="col-12" tal:define="mix_design python:view.get_mix_design()">
<table class="sampleheader-table table table-sm table-bordered">
<tr>
<td class="label bg-light" colspan="8">Additional info</td>
</tr>
<tr>
<td class="" colspan="8">&nbsp;</td>
<td class="" colspan="8"><span tal:content="mix_design/additional_info|nothing"/></td>
</tr>
</table>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/bika/cement/browser/batch/templates/mix_view.pt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<td class="label bg-light" i18n:translate="">Date</td>
<td class="field"><div tal:content="mix_design/date|nothing"/></td>
<td class="label bg-light" i18n:translate="">Type</td>
<td class="field"><div>Concrete</div></td>
<td class="field"><div tal:content="mix_design/get_mix_design_type|nothing"/></td>
</tr>
</table>
</div>
Expand Down
14 changes: 14 additions & 0 deletions src/bika/cement/content/mixdesign.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,17 @@ def get_mix_design_mortar_paste(self):
mortar_paste = [md for md in values if md.portal_type == "MixDesignMortarPaste"]
if len(mortar_paste) == 1:
return mortar_paste[0]

def get_mix_design_type(self):
mix_design = self
mix_design_type = mix_design.mix_design_type
if not mix_design_type:
return

portal_type = api.get_object_by_uid(mix_design_type[0]).portal_type
if not portal_type:
return
if portal_type == "MixDesignConcrete":
return "Concrete"
if portal_type == "MixDesignMortarPaste":
return "Mortar or Paste"
15 changes: 6 additions & 9 deletions src/bika/cement/extenders/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,13 @@ def parse_mix_design_data(self, data):
)
mix_design_data["date"] = datetime
mix_design_data["type"] = data[0][4]
if mix_design_data.get("type") == "Concrete":
mix_design_data["additional_info"] = data[0][7]
# to-do: (mix_materials)
mix_design_data["additional_info"] = data[0][7]
return mix_design_data

def parse_mix_design_concrete_data(self, data):
concrete_data = {}
concrete_data["batch_volume"] = format_number(data[0][6])
concrete_data["design_title"] = data[1][2] # design w/cm (title)
concrete_data["design"] = data[2][2] # design w/cm
concrete_data["replacement"] = format_number(data[1][4])
concrete_data["paste_content"] = format_number(data[1][6])
concrete_data["total_cm"] = format_number(data[2][4])
Expand All @@ -230,7 +228,7 @@ def parse_mix_design_concrete_data(self, data):

def parse_mix_design_mortar_paste_data(self, data):
concrete_data = {}
concrete_data["design_title"] = data[1][2] # design w/cm (title)
concrete_data["design"] = data[2][2] # design w/cm
concrete_data["replacement"] = format_number(data[1][4])
concrete_data["lab_temperature"] = format_number(data[5][4])
concrete_data["mortar_temperature"] = format_number(data[6][4])
Expand All @@ -246,8 +244,7 @@ def create_mix_design(self, batch, data):
mix_design.title = data.get("design_title")
mix_design.project = data.get("project")
mix_design.date = data.get("date")
if data.get("type") == "Concrete":
mix_design.additional_info = data.get("additional_info")
mix_design.additional_info = data.get("additional_info")
# mix_design.mix_design_type = data.get("mix_design_type")
# mix_design.edit(**data)
return mix_design
Expand All @@ -259,7 +256,7 @@ def create_concrete_mix_design(self, mix_design, data):
if not concrete_mix_design:
concrete_mix_design = api.create(mix_design, "MixDesignConcrete")
concrete_mix_design.batch_volume = data.get("batch_volume")
concrete_mix_design.design = data.get("design_title")
concrete_mix_design.design = data.get("design")
concrete_mix_design.replacement = data.get("replacement")
concrete_mix_design.paste_content = data.get("paste_content")
concrete_mix_design.total_cm = data.get("total_cm")
Expand Down Expand Up @@ -288,7 +285,7 @@ def create_mortar_paste_mix_design(self, mix_design, data):
if not mortar_paste_mix_design:
mortar_paste_mix_design = api.create(mix_design, "MixDesignMortarPaste")

mortar_paste_mix_design.design = data.get("design_title")
mortar_paste_mix_design.design = data.get("design")
mortar_paste_mix_design.replacement = data.get("replacement")
mortar_paste_mix_design.lab_temperature = data.get("lab_temperature")
mortar_paste_mix_design.mortar_temperature = data.get("mortar_temperature")
Expand Down

0 comments on commit 39b5f62

Please sign in to comment.