Work on issue 11

This commit is contained in:
2016-09-22 17:31:19 +02:00
parent 20ef745b3f
commit db5ece431b
2 changed files with 36 additions and 34 deletions

View File

@@ -110,13 +110,16 @@
</th>
{% endfor %}
</tr>
{% for mate in tipp_mates %}
{% for mandant in mandant_dict %}
{% for mate in mandant_dict.mandant %}
<tr>
<td>{{ mate.mate.first_name }}</td>
<td>{{ mate.sum_score }}</td>
{% for tipp in mate.tipps %}
<td>{{ tipp }}</td>
{% endfor %}
{% endfor %}
</tr>
{% endfor %}
</table>

View File

@@ -316,22 +316,18 @@ def matchday(request, ls, season, matchday, template_name='md.html'):
values_list('mandant', flat=True)
""" get mates """
tipp_mates = []
mandant_dict = {}
for m in mandants:
mandant = Mandant.objects.get(id=m)
mandant_dict[mandant.name] = []
rs = RelUserMandant.objects.filter(mandant=m)
for r in rs:
"""filter duplicates """
d = False
for item in tipp_mates:
if r.user == item['mate']:
d = True
if d is False:
tipp_mates.append({
'mate': r.user,
'tipps': [],
'sum_score': 0
})
for r in rs:
mandant_dict[mandant.name].append({
'mate': r.user,
'tipps': [],
'sum_score': 0
})
matches = []
for match in md_matches:
@@ -412,25 +408,27 @@ def matchday(request, ls, season, matchday, template_name='md.html'):
f.fields['tippTeam1'].widget.attrs['disabled'] = True
f.fields['tippTeam2'].widget.attrs['disabled'] = True
for mate in tipp_mates:
try:
matetipp = Tipp.objects.get(tipperID=mate['mate'],
matchID=match.matchID)
if match_started is True:
if matetipp.score is None:
score = u'\u231B'
else:
score = matetipp.score
""" get tipps from mates """
for mandant in mandant_dict:
for mate in mandant_dict[mandant]:
try:
matetipp = Tipp.objects.get(tipperID=mate['mate'],
matchID=match.matchID)
if match_started is True:
if matetipp.score is None:
score = u'\u231B'
else:
score = matetipp.score
mate['tipps'].append(str(matetipp.pointsTeam1)
+ ":" + str(matetipp.pointsTeam2)
+ "(" + str(score) + ")")
if match.finished is True:
mate['sum_score'] += matetipp.score
else:
mate['tipps'].append(u'\u2714')
except Exception as e:
mate['tipps'].append(u'\u2717')
mate['tipps'].append(str(matetipp.pointsTeam1)
+ ":" + str(matetipp.pointsTeam2)
+ "(" + str(score) + ")")
if match.finished is True:
mate['sum_score'] += matetipp.score
else:
mate['tipps'].append(u'\u2714')
except Exception as e:
mate['tipps'].append(u'\u2717')
matches.append(item)
@@ -460,8 +458,9 @@ def matchday(request, ls, season, matchday, template_name='md.html'):
'ls': ls,
'season': season,
'username': user,
'tipp_mates': sorted(tipp_mates, key=lambda k: k['sum_score'],
reverse=True),
'mandant_dict': mandant_dict,
#'tipp_mates': sorted(tipp_mates, key=lambda k: k['sum_score'],
#reverse=True),
'posts': posts,
'has_refresh': has_refresh
})