From 4b2f7e4641a21f713c978f11016a559b1f749c2d Mon Sep 17 00:00:00 2001 From: Martin Bley Date: Wed, 8 Jun 2016 08:15:54 +0200 Subject: [PATCH] Finished templates for new HTTP method --- templates/md.html | 27 +++++++++++++++++++++++---- tipp/models.py | 6 ++++++ tipp/views.py | 6 +++++- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/templates/md.html b/templates/md.html index 37d58ca..e0999a8 100644 --- a/templates/md.html +++ b/templates/md.html @@ -58,11 +58,19 @@ {% if match.started and not match.finished %} {% else %}{% endif %} {{ match.matchDateTime }} - + {% if match.iconURLTeam1 != "" %} + + {% else %} + + {% endif %} {{ match.abbrTeam1 }} - + {% if match.iconURLTeam1 != "" %} + + {% else %} + + {% endif %} {{ match.abbrTeam2 }} @@ -87,8 +95,19 @@ Tipper Gesamt {% for match in matches %} -

- + + {% if match.iconURLTeam1 != "" %} + + {% else %} + + {% endif %} +

+ {% if match.iconURLTeam2 != "" %} + + {% else %} + + {% endif %} + {% endfor %} {% for mate in tipp_mates %} diff --git a/tipp/models.py b/tipp/models.py index 36496db..934ef0c 100644 --- a/tipp/models.py +++ b/tipp/models.py @@ -42,10 +42,16 @@ class Team(models.Model): name = models.CharField(max_length=200) icon = models.FileField(upload_to="images/team_logos/") abbr = models.CharField(max_length=3) + iconURL = models.CharField(max_length=2000) def __unicode__(self): return self.name + class Meta: + managed = True + app_label = 'tipp' + + class Match(models.Model): matchID = models.IntegerField(unique=True,primary_key=True) matchDateTime = models.DateTimeField() diff --git a/tipp/views.py b/tipp/views.py index 6e11477..8551fbd 100644 --- a/tipp/views.py +++ b/tipp/views.py @@ -141,10 +141,12 @@ def getSeason(request, ls, season): for team in teams[0]: t = Team( teamID=team['teamID'], - name=team['teamName'] + name=team['teamName'], + iconURL = team['teamIconURL'] ) 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'), @@ -339,9 +341,11 @@ def matchday(request, ls, season, matchday, template_name='md.html'): item['matchDateTime'] = (match.matchDateTime.astimezone(timezoneLocal).strftime('%a %d.%m, %H:%M')) item['iconTeam1']= str(match.idTeam1.icon) + item['iconURLTeam1'] = str(match.idTeam1.iconURL) item['nameTeam1']= str(match.idTeam1) item['abbrTeam1']= str(match.idTeam1.abbr) item['iconTeam2'] = str(match.idTeam2.icon) + item['iconURLTeam2'] = str(match.idTeam2.iconURL) item['nameTeam2'] = str(match.idTeam2) item['abbrTeam2']= str(match.idTeam2.abbr) item['started'] = match_started