diff --git a/.gitignore b/.gitignore
index 3900625..ff84a21 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@ static/
templates/blogindex.html-media
tippy/static/
warnings.txt
+tags
diff --git a/templates/adminpage.html b/templates/adminpage.html
new file mode 100644
index 0000000..233c711
--- /dev/null
+++ b/templates/adminpage.html
@@ -0,0 +1,62 @@
+{% extends "base.html" %}
+{% load i18n static %}
+{% load humanize %}
+{% block head %}
+
+{% endblock %}
+
+{% block nav %}
+{% include "nav.html" with ls=ls season=season %}
+{% endblock %}
+
+{% block body %}
+
+
+
+
Aktivierte Ligen
+
+
+ | Liga |
+ Abkürzung |
+
+ {% for i in leagues %}
+
+ | {{ i.leagueName }} |
+ {{ i.leagueShortcut }} |
+
+ {% endfor %}
+
+
+
+
+
+
Verfügbare Ligen
+
+
+ | Liga |
+ Abkürzung |
+ Saison |
+ ID |
+
+ {% for i in avail_leagues %}
+
+ | {{ i.leagueName }} |
+ {{ i.leagueShortcut }} |
+ {{ i.leagueSaison }} |
+ {{ i.leagueID }} |
+
+ {% endfor %}
+
+
+
+ {% if debug %}
+
+
+ {% for line in debug %}
+
{{ line }}
+ {% endfor %}
+
+
+ {% endif %}
+
+{% endblock %}
diff --git a/templates/nav.html b/templates/nav.html
index 2fff481..ec4ef7f 100644
--- a/templates/nav.html
+++ b/templates/nav.html
@@ -16,6 +16,9 @@
Tipps
Bestenliste
Blog
+ {% if user.is_superuser %}
+ Admin
+ {% endif %}
{% if has_refresh %}
diff --git a/tipp/models.py b/tipp/models.py
index e272d25..b80c04e 100644
--- a/tipp/models.py
+++ b/tipp/models.py
@@ -64,6 +64,7 @@ class Match(models.Model):
pointsTeam2 = models.SmallIntegerField()
finished = models.BooleanField()
season = models.CharField(max_length=4)
+ #leagueShortcut = models.ForeignKey(Competition)
leagueShortcut = models.CharField(max_length=12)
def __unicode__(self):
diff --git a/tipp/openliga.py b/tipp/openliga.py
index 6fbcf20..b02f888 100644
--- a/tipp/openliga.py
+++ b/tipp/openliga.py
@@ -86,5 +86,7 @@ class OpenLiga(object):
leagueShortcut=league)
)
+ def getAvailLeagues(self):
+ return(self.client.service.GetAvailLeaguesBySports(1))
diff --git a/tipp/views.py b/tipp/views.py
index 3635d3a..fe4854c 100644
--- a/tipp/views.py
+++ b/tipp/views.py
@@ -23,7 +23,7 @@ from django.shortcuts import render_to_response, redirect, render, \
get_object_or_404
from django.contrib.auth import authenticate, login
from django.contrib.auth.models import User
-from django.contrib.auth.decorators import login_required
+from django.contrib.auth.decorators import login_required, user_passes_test
from django.contrib.auth.views import password_reset, \
password_reset_confirm
from django.core.context_processors import csrf
@@ -146,8 +146,32 @@ def profile(request, pk):
'img': img}
)
+@user_passes_test(lambda u: u.is_superuser)
+def adminpage(request, pos='default', template_name='adminpage.html'):
+ debug = []
+ lss = Match.objects.values('leagueShortcut').distinct(). \
+ values_list('leagueShortcut', flat=True)
+ leagues = Competition.objects.values('leagueShortcut', 'leagueName').filter(leagueShortcut__in=lss)
+
+ ol = OpenLiga()
+
+ avail_leagues = []
+ for l in ol.getAvailLeagues()[0]:
+ if int(l["leagueSaison"]) >= int(get_current_season()):
+ avail_leagues.append({
+ 'leagueID' : l["leagueID"],
+ 'leagueShortcut' : l["leagueShortcut"],
+ 'leagueName' : l["leagueName"],
+ 'leagueSaison' : l["leagueSaison"]
+ })
+
+ return render(request, template_name, {
+ 'debug': debug,
+ 'leagues': leagues,
+ 'avail_leagues': avail_leagues
+ })
+
-@login_required
def getSeason(request, ls, season):
ol = OpenLiga()
teams = ol.getTeams(str(season), ls)
diff --git a/tippy/urls.py b/tippy/urls.py
index 08fe992..6aa72a5 100644
--- a/tippy/urls.py
+++ b/tippy/urls.py
@@ -26,6 +26,7 @@ urlpatterns = patterns('',
url(r'^accounts/', include('django.contrib.auth.urls')),
url(r'^blog/newpost$', 'tipp.views.newBlogpost'),
url(r'^blog/(?P\d)$', 'tipp.views.blogindex'),
+ url(r'^adminpage$', 'tipp.views.adminpage'),
url(r'^about$', 'tipp.views.about'),
# Uncomment the admin/doc line below to enable admin documentation: