Skip to content

Commit

Permalink
fix: handle missing family history template
Browse files Browse the repository at this point in the history
  • Loading branch information
dianekaplan committed Nov 11, 2021
1 parent 999f6a6 commit 03b7ec8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
20 changes: 14 additions & 6 deletions mysite/familytree/templates/familytree/history.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@ <h2>Family history: </h2>
{% if profile.connection_notes %}
<p>{{ profile.connection_notes }}</p>
{% endif %}
{% for branch in accessible_branches %}
{% get_history_filepath branch as filepath %}
<div class="circled_section">
{% include filepath %}
</div>
{% endfor %}

{% for branch in accessible_branches %}
{% get_history_filepath branch as filepath %}
{% template_exists filepath as result %}

<div class="circled_section">
{% if result %}
{% include filepath %}
{% else %}
{{branch}} history still to be written <br/>
Add it here: {{filepath}}
{% endif %}
</div>

{% endfor %}
{% endblock content %}
11 changes: 11 additions & 0 deletions mysite/familytree/templatetags/familytree_extras.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
from django import template
from django.template.defaultfilters import stringfilter
from django.utils.timesince import timesince

register = template.Library()

# @register.filter
# @stringfilter
@register.simple_tag
def template_exists(value):
try:
template.loader.get_template(value)
return True
except template.TemplateDoesNotExist:
return False


@register.simple_tag
def generation_class(generation_int):
Expand Down

0 comments on commit 03b7ec8

Please sign in to comment.