added a league selector to the menu bar
This commit is contained in:
parent
f771d608f8
commit
3319cbe3b0
@ -44,9 +44,17 @@
|
||||
<a class="brand" href="#"><img src="{% static "images/duck.png" %}" width="30" height="30"> </a>
|
||||
<div class="nav-collapse">
|
||||
<ul class="nav">
|
||||
<li {% if view == "league" %}class="active"{%endif%}><a href="{% url league 1 %}">League</a></li>
|
||||
<li {% if view == "events" %}class="active"{%endif%}><a href="{% url events 1 %}">Events</a></li>
|
||||
<li {% if view == "roster" %}class="active"{%endif%}><a href="{% url roster %}">Roster</a></li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{{league}}<b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
{% for league in leagues %}
|
||||
<li><a href="{% url league league.id %}">{{league}}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
<li {% if view == "league" %}class="active"{%endif%}><a href="{% url league league.id %}">League</a></li>
|
||||
<li {% if view == "events" %}class="active"{%endif%}><a href="{% url events league.id %}">Events</a></li>
|
||||
<li {% if view == "roster" %}class="active"{%endif%}><a href="{% url roster league.id %}">Roster</a></li>
|
||||
</ul>
|
||||
</div><!--/.nav-collapse -->
|
||||
</div>
|
||||
@ -66,6 +74,7 @@
|
||||
|
||||
<script src="{% static "js/jquery.js" %}"></script>
|
||||
<script src="{% static "js/bootstrap-collapse.js" %}"></script>
|
||||
<script src="{% static "js/bootstrap-dropdown.js" %}"></script>
|
||||
<!--
|
||||
<script src="assets/js/bootstrap-transition.js"></script>
|
||||
<script src="assets/js/bootstrap-alert.js"></script>
|
||||
|
@ -6,5 +6,5 @@ urlpatterns = patterns('',
|
||||
url(r'league/(?P<league_id>\d+)/$', 'fowl.game.views.league',
|
||||
name='league'),
|
||||
url(r'^edit_event/$', 'fowl.game.views.edit_event', name='edit_event'),
|
||||
url(r'^roster/$', 'fowl.game.views.roster', name='roster'),
|
||||
url(r'^roster/(?P<league_id>\d+)/$', 'fowl.game.views.roster', name='roster'),
|
||||
)
|
||||
|
@ -1,9 +1,10 @@
|
||||
from itertools import izip_longest
|
||||
from django.shortcuts import render, get_object_or_404
|
||||
from fowl.game.models import Team, TeamPoints, Star, Event
|
||||
from fowl.game.models import Team, TeamPoints, Star, Event, League
|
||||
|
||||
|
||||
def events(request, league_id):
|
||||
league = get_object_or_404(League, pk = league_id)
|
||||
events = {}
|
||||
points = TeamPoints.objects.filter(team__league_id=league_id).order_by(
|
||||
'match', 'team').select_related()
|
||||
@ -18,7 +19,7 @@ def events(request, league_id):
|
||||
events[event_id].scores.setdefault(tp.team, 0)
|
||||
events[event_id].scores[tp.team] += tp.points
|
||||
events = sorted(events.values(), key=lambda x: x.date, reverse=True)
|
||||
return render(request, "events.html", {'events': events, 'view': 'events'})
|
||||
return render(request, "events.html", {'events': events, 'view': 'events', 'league': league})
|
||||
|
||||
|
||||
def edit_event(request, event_id=None):
|
||||
@ -31,9 +32,13 @@ def edit_event(request, event_id=None):
|
||||
|
||||
|
||||
def league(request, league_id):
|
||||
league = get_object_or_404(League, pk = league_id)
|
||||
leagues = League.objects.all()
|
||||
context = {
|
||||
'view': 'league',
|
||||
'belts': ['ic', 'us', 'heavyweight', 'wwe']
|
||||
'belts': ['ic', 'us', 'heavyweight', 'wwe'],
|
||||
'league': league,
|
||||
'leagues': leagues
|
||||
}
|
||||
teams = list(Team.objects.filter(league__id=league_id)
|
||||
.prefetch_related('stars'))
|
||||
@ -43,9 +48,13 @@ def league(request, league_id):
|
||||
return render(request, "stables.html", context)
|
||||
|
||||
|
||||
def roster(request):
|
||||
def roster(request, league_id):
|
||||
league = get_object_or_404(League, pk = league_id)
|
||||
leagues = League.objects.all()
|
||||
context = {
|
||||
'stars': Star.objects.all(),
|
||||
'view': 'roster'
|
||||
'view': 'roster',
|
||||
'league': league,
|
||||
'leagues': leagues
|
||||
}
|
||||
return render(request, "roster.html", context)
|
||||
|
Loading…
Reference in New Issue
Block a user