From c0eb583a69bb8b45f58d3345cc39f12f5d2e67a8 Mon Sep 17 00:00:00 2001 From: Martin Bley Date: Tue, 7 Jun 2016 17:22:28 +0200 Subject: [PATCH] import function created --- tipp/views.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tipp/views.py b/tipp/views.py index e64bd89..932afa9 100644 --- a/tipp/views.py +++ b/tipp/views.py @@ -131,6 +131,28 @@ def profile(request, pk): 'img': img} ) +@login_required +def import(request, ls, season): + + ol = OpenLiga() + season = ol.getSeason(str(season), ls) + + for match in season[0]: + m = Match(matchID=unicode(match['matchID']), + matchDateTime=datetime.strptime(unicode(match['matchDateTime']), '%Y-%m-%d %H:%M:%S'), + group=int(match['groupID']), + matchday=int(match['groupOrderID']), + idTeam1=Team.objects.get(teamID=int(match['idTeam1'])), + idTeam2=Team.objects.get(teamID=int(match['idTeam2'])), + pointsTeam1=pointsTeam1, + pointsTeam2=pointsTeam2, + finished=bool(match['matchIsFinished']), + season=match['leagueSaison'], + leagueShortcut=match['leagueShortcut'] + ) + m.save() + + @login_required def update(request, ls, season, cur_md): """