Fix templates not to fail when footer or nav don't exist

master
David Beltra 4 years ago
parent 15f1960ab4
commit c2a253e7a9

1
.gitignore vendored

@ -31,6 +31,7 @@ venv.bak/
#local db, must run migrations on production to sync
dev.db
data.json
#credentials
credentials.sh

@ -1,9 +1,15 @@
from mezzanine.pages.models import Page
def footer(request):
footer_page = Page.objects.get(id=13)
return {'footer_page': footer_page}
if Page.objects.filter(slug='footer').exists():
footer_page = Page.objects.get(slug='footer')
return {'footer_page': footer_page}
else:
return {'footer_page': None}
def navbar(request):
navbar_page = Page.objects.get(id=11)
return {'navbar_page': navbar_page}
if Page.objects.filter(slug='navbar').exists():
navbar_page = Page.objects.get(slug='navbar')
return {'navbar_page': navbar_page}
else:
return {'navbar_page': None}

@ -54,9 +54,11 @@
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="nav-logo">
<div class="container">
{% if navbar_page %}
{% editable navbar_page.get_content_model.image %}
<a href="/"><img src="{{ MEDIA_URL }}{{ navbar_page.get_content_model.image}}" alt=""{{navbar_page.title}}></a>
{% endeditable %}
{% endif %}
</div>
</div>
<div class="container">
@ -116,6 +118,7 @@
<footer>
<div class="container">
<div class="row">
{% if footer_page %}
<div class="col-md-4">
{% editable footer_page.get_content_model.text_1 %}
{{ footer_page.get_content_model.text_1 | safe }}
@ -131,6 +134,7 @@
{{ footer_page.get_content_model.text_3 | safe }}
{% endeditable %}
</div>
{% endif %}
</div>
</div>
</footer>

Loading…
Cancel
Save