fix next_event and previous_event if there isn't one
This commit is contained in:
@@ -1,18 +1,22 @@
|
|||||||
{% extends 'base.html' %}{% block title %} {{ title }} {% endblock %}{% load crispy_forms_tags %}{% load static %}
|
{% extends 'base.html' %}{% block title %} {{ title }} {% endblock %}{% load crispy_forms_tags %}{% load static %}
|
||||||
{% with events_active="active" %}
|
{% with events_active="active" %}
|
||||||
{% block precontent %}
|
{% block precontent %}
|
||||||
<div class="d-flex justify-content-center justify-content-md-center border-bottom bg-white">
|
<div class="d-flex justify-content-center justify-content-md-center border-bottom bg-white">
|
||||||
|
{% if previous_event %}
|
||||||
<a class="btn btn-outline-secondary btn-sm d-md-flex my-auto align-items-md-center my-3 mx-3" href="{% url 'edit lineup' event_id=previous_event.id %}" role="button">
|
<a class="btn btn-outline-secondary btn-sm d-md-flex my-auto align-items-md-center my-3 mx-3" href="{% url 'edit lineup' event_id=previous_event.id %}" role="button">
|
||||||
<i class="bi bi-chevron-left"></i>{{ previous_event.start|date:"D" }} {{ previous_event.start|date:"n/j" }}
|
<i class="bi bi-chevron-left"></i>{{ previous_event.start|date:"D" }} {{ previous_event.start|date:"n/j" }}
|
||||||
</a>
|
</a>
|
||||||
|
{% endif %}
|
||||||
<div>
|
<div>
|
||||||
<h5 class="text-center m-1">{{ event.away_team.name }} vs. {{ event.home_team.name }}</h5>
|
<h5 class="text-center m-1">{{ event.away_team.name }} vs. {{ event.home_team.name }}</h5>
|
||||||
<p class="text-center text-muted m-1">{{ event.start|date:"l, F j, Y g:i A" }}<br>{{ event.venue.name }}</p>
|
<p class="text-center text-muted m-1">{{ event.start|date:"l, F j, Y g:i A" }}<br>{{ event.venue.name }}</p>
|
||||||
<h6 class="text-muted m-1"></h6>
|
<h6 class="text-muted m-1"></h6>
|
||||||
</div>
|
</div>
|
||||||
|
{% if next_event %}
|
||||||
<a class="btn btn-outline-secondary btn-sm align-items-center my-auto my-3 mx-3" href="{% url 'edit lineup' event_id=next_event.id %}" role="button">
|
<a class="btn btn-outline-secondary btn-sm align-items-center my-auto my-3 mx-3" href="{% url 'edit lineup' event_id=next_event.id %}" role="button">
|
||||||
{{ next_event.start|date:"D" }} {{ next_event.start|date:"n/j" }}<i class="bi bi-chevron-right"></i>
|
{{ next_event.start|date:"D" }} {{ next_event.start|date:"n/j" }}<i class="bi bi-chevron-right"></i>
|
||||||
</a>
|
</a>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ul class="nav nav-pills nav-fill bg-white" role="tablist">
|
<ul class="nav nav-pills nav-fill bg-white" role="tablist">
|
||||||
@@ -20,7 +24,7 @@
|
|||||||
<li class="nav-item m-1" role="presentation"><a id="event-lineup-tab" class="nav-link px-2 py-0" data-bs-toggle="pill" data-bs-target="#event-lineup" role="tab" aria-controls="event-lineup" aria-selected="false">Lineup</a></li>
|
<li class="nav-item m-1" role="presentation"><a id="event-lineup-tab" class="nav-link px-2 py-0" data-bs-toggle="pill" data-bs-target="#event-lineup" role="tab" aria-controls="event-lineup" aria-selected="false">Lineup</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
{% endblock %}{% endwith %}
|
{% endblock %}{% endwith %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div id="pills-tabContent" class="container-fluid tab-content my-1" data-toggle="tab">
|
<div id="pills-tabContent" class="container-fluid tab-content my-1" data-toggle="tab">
|
||||||
<div id="event-details" class="tab-pane show active" role="tabpanel" aria-labelledby="event-details-tab">
|
<div id="event-details" class="tab-pane show active" role="tabpanel" aria-labelledby="event-details-tab">
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ def edit(request, event_id):
|
|||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
return render(request, 'success.html', {'call_back':'edit lineup','id':event_id, 'errors':[error for error in formset.errors if error]}, status=200)
|
return render(request, 'success.html', {'call_back':'edit lineup','id':event_id, 'errors':[error for error in formset.errors if error]}, status=200)
|
||||||
previous_event = Event.objects.get(id=event_id-1)
|
previous_event = Event.objects.filter(id=event_id-1).first()
|
||||||
|
|
||||||
event = Event.objects.get(id=event_id)
|
event = Event.objects.get(id=event_id)
|
||||||
next_event = Event.objects.get(id=event_id+1)
|
next_event = Event.objects.get(id=event_id+1)
|
||||||
@@ -86,7 +86,8 @@ def edit(request, event_id):
|
|||||||
}
|
}
|
||||||
|
|
||||||
return render(request, 'lineups/lineup.html', {'title': 'Lineup',
|
return render(request, 'lineups/lineup.html', {'title': 'Lineup',
|
||||||
'event': event, 'details':details,
|
'event': event,
|
||||||
|
'details':details,
|
||||||
'previous_event': previous_event,
|
'previous_event': previous_event,
|
||||||
'next_event': next_event,
|
'next_event': next_event,
|
||||||
'formset': formset,
|
'formset': formset,
|
||||||
|
|||||||
Reference in New Issue
Block a user