Skip to content

Commit

Permalink
Merge pull request #389 from rcpch:can-push-to-live
Browse files Browse the repository at this point in the history
Cant-push-to-live
  • Loading branch information
eatyourpeas authored Nov 19, 2024
2 parents a9ac3ca + 8147868 commit e77f3bc
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 18 deletions.
39 changes: 21 additions & 18 deletions project/npda/templates/npda/visit_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
{% if field.field.category == field_category %}
<div class="flex flex-row flex-wrap my-2 mx-2">
<div class="flex items-center justify-start w-full md:w-1/3">
{% if field.id_for_label == 'id_height' or field.id_for_label == 'id_weight' %}
{% is_not_excluded_centile_field field as included_field %}
{% if included_field %}
<label for="{{ field.id_for_label }}" class="block text-gray-700 font-bold mb-1 md:mb-0 pr-4"><small>{{ field.label }}</small></label>
{% endif %}
</div>
Expand All @@ -98,26 +99,28 @@
</div>
{% else %}

<!-- these are the field labels: do not want to show centile/sds -->
{% if field.id_for_label == 'id_height' or field.id_for_label == 'id_weight' or field.id_for_label == 'id_bmi' %}
<!-- these are the field inputs: do not want to show centile/sds -->
{% is_not_excluded_centile_field field as included_field %}
{% if included_field or field.id_for_label == 'id_bmi' %}

{% if field.id_for_label == 'id_bmi' %}
<label for="{{ field.id_for_label }}" class="block text-gray-700 font-bold mb-1 md:mb-0 pr-4"><small>Body Mass Index: {{ field.value }} kg/m²</small></label>
{% else %}
<input type="text" id="{{ field.id_for_label }}" name="{{ field.html_name }}" class="input rcpch-input-text rounded-none" {% if field.field.required %} placeholder="Required" {% endif %} {% if field.value %} value={{ field.value }} {% elif field.value == 0 %} value="0.0" {% endif %}>
{% endif %}
{% if field.id_for_label == 'id_bmi' %}
<label for="{{ field.id_for_label }}" class="block text-gray-700 font-bold mb-1 md:mb-0 pr-4"><small>Body Mass Index: {{ field.value }} kg/m²</small></label>
{% else %}
<input type="text" id="{{ field.id_for_label }}" name="{{ field.html_name }}" class="input rcpch-input-text rounded-none" {% if field.field.required %} placeholder="Required" {% endif %} {% if field.value %} value={{ field.value }} {% elif field.value == 0 %} value="0.0" {% endif %}>
{% endif %}

{% centile_sds field as centile_sds %}
{% with centile=centile_sds.0 sds=centile_sds.1 %}
{% if centile %}
<span>
<label><small>Centile: {{centile}}</small></label>
<label><small>SDS: {{sds}}</small></label>
{% endif %}
</span>
{% endwith %}
{% centile_sds field as centile_sds %}
{% with centile=centile_sds.0 sds=centile_sds.1 %}
{% if centile %}
<span>
<label><small>Centile: {{centile}}</small></label>
<label><small>SDS: {{sds}}</small></label>
{% endif %}
</span>
{% endwith %}

{% endif %}
{% endif %}


{% endif %}
{% for error in field.errors %}
Expand Down
16 changes: 16 additions & 0 deletions project/npda/templatetags/npda_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,22 @@ def centile_sds(field):
return centile, sds


@register.simple_tag
def is_not_excluded_centile_field(field):
exclude = [
"id_height_centile",
"id_height_sds",
"id_weight_centile",
"id_weight_sds",
"id_bmi_centile",
"id_bmi_sds",
"id_bmi",
]
if field.id_for_label not in exclude:
return True
return False


@register.filter
def join_with_comma(value):
if isinstance(value, list):
Expand Down

0 comments on commit e77f3bc

Please sign in to comment.