3 Commits
chat ... iss16

Author SHA1 Message Date
2fa6dd0709 Keine Ahnung / not known 2018-06-22 15:03:25 +02:00
91f210883f stuff on adminpage 2017-10-03 18:31:14 +02:00
c21e0d3292 added new page for admistrative purpose 2017-10-02 18:59:30 +02:00
8 changed files with 115 additions and 5 deletions

1
.gitignore vendored
View File

@@ -8,3 +8,4 @@ static/
templates/blogindex.html-media
tippy/static/
warnings.txt
tags

68
templates/adminpage.html Normal file
View File

@@ -0,0 +1,68 @@
{% extends "base.html" %}
{% load i18n static %}
{% load humanize %}
{% block head %}
<script type="text/javascript" src="{{ STATIC_URL }}javascript/tippy.js"></script>
{% endblock %}
{% block nav %}
{% include "nav.html" with ls=ls season=season %}
{% endblock %}
{% block body %}
<div id="content-main">
<div class="row">
<div class="col-md-7">
<h2>Aktivierte Ligen</h2>
<table class="table table-striped">
<tr>
<th>Liga</th>
<th>Abkürzung</th>
</tr>
{% for i in leagues %}
<tr>
<td>{{ i.leagueName }}</td>
<td>{{ i.leagueShortcut }}</td>
</tr>
{% endfor %}
</table>
</div>
</div>
<div class="row">
<div class="col-md-7">
<button class="btn btn-primary" type="button" data-toggle="collapse"
data-target="#collapseBeispiel" aria-expanded="false" aria-controls="collapseBeispiel">
Liga hinzufügen</button>
<div class="collapse" id="collapseBeispiel">
<form role="form" action="" method="post">{% csrf_token %}
<table class="table table-striped">
<tr>
<th>Liga</th>
<th>Abkürzung</th>
<th>Saison</th>
<th>ID</th>
</tr>
{% for i in avail_leagues %}
<tr>
<td>{{ i.leagueName }}</td>
<td>{{ i.leagueShortcut }}</td>
<td>{{ i.leagueSaison }}</td>
<td>{{ i.leagueID }}</td>
</tr>
{% endfor %}
</table>
</form>
</div>
</div>
</div>
{% if debug %}
<div class="row">
<div class="col-md-7">
{% for line in debug %}
<p>{{ line }}</p>
{% endfor %}
</div>
</div>
{% endif %}
</div>
{% endblock %}

View File

@@ -16,6 +16,9 @@
<li><a href="/">Tipps</a></li>
<li><a href="/charts/{{ ls }}/{{ season }}{% if pos %}/{{ pos }}{% endif %}">Bestenliste</a></li>
<li><a href="/blog/1">Blog</a></li>
{% if user.is_superuser %}
<li><a href="/adminpage">Admin</a></li>
{% endif %}
</ul>
<ul class="nav navbar-nav navbar-right">
{% if has_refresh %}

View File

@@ -55,8 +55,8 @@ class BlogpostForm(ModelForm):
class MandantsForm(forms.Form):
mandants = forms.MultipleChoiceField(
label= "Posten in",
widget=forms.CheckboxSelectMultiple({'checked':'checked'})
label= "Posten in ",
widget=forms.CheckboxSelectMultiple({'checked':'checked'})
)
class UserForm(forms.ModelForm):
@@ -69,3 +69,9 @@ class UserProfileForm(forms.ModelForm):
model = UserProfile
fields = ['avatar']
class LeagueImportForm(forms.Form):
leagues = forms.ChoiceField(
widget=forms.RadioSelect()
)

View File

@@ -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):

View File

@@ -86,5 +86,7 @@ class OpenLiga(object):
leagueShortcut=league)
)
def getAvailLeagues(self):
return(self.client.service.GetAvailLeaguesBySports(1))

View File

@@ -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
@@ -142,12 +142,40 @@ def profile(request, pk):
return render(request, 'registration/profile.html', {
'user_form': user_form,
'profile_form': profile_form,
'debug': debug,
#'debug': debug,
'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"]
})
form_leagues = LeagueImportForm()
form_leagues.fields["leagues"].choices = avail_leagues
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)

View File

@@ -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<page>\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: