Commit 8c2bf0bc authored by Lukas Burgey's avatar Lukas Burgey

Simplify the urls

parent 382e53fd
......@@ -61,7 +61,7 @@ MIDDLEWARE = [
ROOT_URLCONF = 'django_skat.urls'
LOGIN_REDIRECT_URL = 'playerstats'
LOGIN_REDIRECT_URL = 'eventstats'
TEMPLATES = [
{
......
......@@ -35,8 +35,8 @@
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li><a href="{% url 'results' %}">Results</a></li>
<li><a href="{% url 'playerstats' page=1 %}">EventStats</a></li>
<li><a href="{% url 'playerstats' page=3 %}">OverallStats</a></li>
<li><a href="{% url 'eventstats' %}">EventStats</a></li>
<li><a href="{% url 'overallstats' %}">OverallStats</a></li>
<li><a href="{% url 'combinatorics' %}">Math</a></li>
{% block nav-playerpage %}{% endblock %}
</ul>
......@@ -50,6 +50,7 @@
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="{% url 'event' %}">Event Details</a></li>
{% for it in its %}<li>
<form action="{% url 'select_iteration' %}" method="post">
{% csrf_token %}
......
......@@ -4,13 +4,10 @@ from django.views.generic import RedirectView
from . import views
urlpatterns = [
url(r'^$', RedirectView.as_view(url='playerstats'), name='index'),
url(r'^results(?:/iteration-(?P<it>\d+))?/$',
views.Results.as_view(),
name='results'),
url(r'^playerstats(?:/page-(?P<page>\d+)(?:/iteration-(?P<it>\d+))?)?/$',
views.PlayerStats.as_view(),
name='playerstats'),
url(r'^$', RedirectView.as_view(url='eventstats'), name='index'),
url(r'^results$', views.Results.as_view(), name='results'),
url(r'^eventstats$', views.EventStats.as_view(), name='eventstats'),
url(r'^overallstats$', views.OverallStats.as_view(), name='overallstats'),
url(r'^combinatorics$', views.Combinatorics.as_view(), name='combinatorics'),
url(r'^flushcache$', views.flush_cache, name='flush_cache'),
url(r'^submit$', views.submit, name='submit'),
......
......@@ -71,8 +71,30 @@ class PlayerStats(View):
context['win_percentage'] = models.Game.win_percentage(None)
context['player_list'] = models.overall_player_info()
return render(request, 'skat/playerstats1.html', context)
else:
return render(request, 'skat/playerstats1.html', context)
class EventStats(View):
def get(self, request, **kwargs):
context = request_context(request)
context['title'] = "Stats: {}".format(context['it'])
context['game_count_per_type'] = models.game_count_per_type(context['it'])
context['best_player_per_type'] = models.best_player_per_type(context['it'])
context['won_list'] = models.won_list(context['it'])
context['win_percentage'] = models.Game.win_percentage(context['it'])
context['player_list'] = models.iteration_player_info(context['it'])
return render(request, 'skat/playerstats1.html', context)
class OverallStats(View):
def get(self, request, **kwargs):
context = request_context(request)
# Overall stats have no iteration, so we use None instead
context['title'] = "Stats: Overall"
context['game_count_per_type'] = models.game_count_per_type(None)
context['best_player_per_type'] = models.best_player_per_type(None)
context['won_list'] = models.won_list(None)
context['win_percentage'] = models.Game.win_percentage(None)
context['player_list'] = models.overall_player_info()
return render(request, 'skat/playerstats1.html', context)
class PlayerPage(View):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment