diff --git a/tipp/views.py b/tipp/views.py index 932afa9..ae1127f 100644 --- a/tipp/views.py +++ b/tipp/views.py @@ -131,12 +131,20 @@ def profile(request, pk): 'img': img} ) -@login_required -def import(request, ls, season): +@login_required +def getSeason(request, ls, season): ol = OpenLiga() + teams = ol.getTeams(str(season), ls) season = ol.getSeason(str(season), ls) + for team in teams[0]: + t = Team( + teamID=team['teamID'], + name=team['teamName'] + ) + t.save() + for match in season[0]: m = Match(matchID=unicode(match['matchID']), matchDateTime=datetime.strptime(unicode(match['matchDateTime']), '%Y-%m-%d %H:%M:%S'), @@ -144,13 +152,15 @@ def import(request, ls, season): matchday=int(match['groupOrderID']), idTeam1=Team.objects.get(teamID=int(match['idTeam1'])), idTeam2=Team.objects.get(teamID=int(match['idTeam2'])), - pointsTeam1=pointsTeam1, - pointsTeam2=pointsTeam2, + pointsTeam1=match['pointsTeam1'], + pointsTeam2=match['pointsTeam2'], finished=bool(match['matchIsFinished']), season=match['leagueSaison'], leagueShortcut=match['leagueShortcut'] ) m.save() + + return redirect("matchday", ls=ls, season=season, matchday=get_current_md(ls, season)) @login_required @@ -532,8 +542,8 @@ def get_current_md(ls,season): return(current_md) def get_current_ls(): - return("bl1") + return("em2016") def get_current_season(): - return("2015") + return("2016") diff --git a/tippy/urls.py b/tippy/urls.py index bef923f..bf4b38e 100644 --- a/tippy/urls.py +++ b/tippy/urls.py @@ -10,7 +10,7 @@ urlpatterns = patterns('', url(r'^$', 'tipp.views.home', name='home'), url(r'^login$', 'django.contrib.auth.views.login', {'template_name': 'login.html'}), url(r'^logout$', 'django.contrib.auth.views.logout', {'next_page': '/'}), - url(r'^import/(?P.*)/(?P\d{4})$', 'tipp.views.import', name='import'), + url(r'^getSeason/(?P.*)/(?P\d{4})$', 'tipp.views.getSeason'), url(r'^update/(?P.*)/(?P\d{4})/(?P\d{2})$', 'tipp.views.update', name='update'), url(r'^matchday/(?P.{3,})/(?P\d{4})/(?P\d{2})$', 'tipp.views.matchday', name='matchday'), url(r'^charts/(?P\w{3,})/(?P\d{4})$', 'tipp.views.charts', name='charts'),