Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

Commit

Permalink
Render 'People of all ages are welcome'
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeard4 committed Jun 12, 2024
1 parent d0e804d commit 92ca2b5
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 29 deletions.
38 changes: 22 additions & 16 deletions components/location_service/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,24 +130,30 @@ <h3 class="text-dark text-lg font-medium leading-3">
</p>
{% endfor %}

{% if service.age|length == 1 %}
{% if service.age|contains_all_ages_requirement %}
<p class="text-dark text-sm">
Age requirement: {{service.age.0|render_age_eligibility}}
People of all ages are welcome
</p>
{% endif %}
{% if service.age|length > 1 %}
<p class="text-dark text-sm">
Age requirements:
</p>
<ul class="flex flex-col space-y-3">
{% for age_req in service.age %}
<li class="flex items-start space-x-2">
<p class="text-dark text-sm">
{{age_req|render_age_eligibility}}
</p>
</li>
{% endfor %}
</ul>
{% else %}
{% if service.age|length == 1 %}
<p class="text-dark text-sm">
Age requirement: {{service.age.0|render_age_eligibility}}
</p>
{% endif %}
{% if service.age|length > 1 %}
<p class="text-dark text-sm">
Age requirements:
</p>
<ul class="flex flex-col space-y-3">
{% for age_req in service.age %}
<li class="flex items-start space-x-2">
<p class="text-dark text-sm">
{{age_req|render_age_eligibility}}
</p>
</li>
{% endfor %}
</ul>
{% endif %}
{% endif %}
</div>
</li>
Expand Down
29 changes: 16 additions & 13 deletions streetlives/templatetags/jsonify.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,25 @@ def jsonify(object):
register.filter('jsonify', jsonify)

def render_age_eligibility(age_req):
if age_req['all_ages']:
return 'People of all ages are welcome'
else:
s = ''
if age_req['age_min'] and age_req['age_max']:
s = f'{age_req["age_min"]}-{age_req["age_max"]}'
elif age_req['age_min']:
s = f'{age_req["age_min"]}+'
elif age_req['age_max']:
s = f'Under {age_req["age_max"]}'
if age_req['population_served']:
s += f(" ({age_req['population_served']})")
return s
s = ''
if age_req['age_min'] and age_req['age_max']:
s = f'{age_req["age_min"]}-{age_req["age_max"]}'
elif age_req['age_min']:
s = f'{age_req["age_min"]}+'
elif age_req['age_max']:
s = f'Under {age_req["age_max"]}'
if age_req['population_served']:
s += f(" ({age_req['population_served']})")
return s

register.filter('render_age_eligibility', render_age_eligibility)


def contains_all_ages_requirement(age_reqs):
return bool([req for req in age_reqs if req['all_ages']])

register.filter('contains_all_ages_requirement', contains_all_ages_requirement)

def format_website_url(url):
print(url)
if not url:
Expand Down

0 comments on commit 92ca2b5

Please sign in to comment.