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