Added a setting where the exported excel files should be stored.
Added a option to send the exported excel as mail attachment.
This commit is contained in:
@@ -4,7 +4,9 @@
|
||||
# werden dürfen.
|
||||
|
||||
from __future__ import division
|
||||
|
||||
from datetime import datetime, time
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.urlresolvers import reverse
|
||||
@@ -463,8 +465,12 @@ class KyuDanRanking(models.Model):
|
||||
datetime.combine(self.legacy_date, time(0, 0, 0)))
|
||||
else:
|
||||
since = None
|
||||
else:
|
||||
since = self.last_hanchan_date or self.legacy_date
|
||||
elif self.last_hanchan_date:
|
||||
since = self.last_hanchan_date
|
||||
elif self.legacy_date:
|
||||
since = timezone.make_aware(
|
||||
datetime.combine(self.legacy_date, time(0, 0, 0))
|
||||
)
|
||||
LOGGER.info(
|
||||
"recalculating Kyu/Dan points for %(user)s since %(since)s...",
|
||||
{'user': self.user, 'since': str(since)}
|
||||
@@ -474,13 +480,11 @@ class KyuDanRanking(models.Model):
|
||||
if until:
|
||||
valid_hanchans = valid_hanchans.filter(start__lte=until)
|
||||
|
||||
""" TODO: Hanchan Punkte nur neu berechnen wenn sie nach hachan_start
|
||||
lagen. Es müssen aber alle durch die Schleife rennen, damit die Punkte
|
||||
richtig gezählt werden."""
|
||||
self.hanchan_count += valid_hanchans.count()
|
||||
for hanchan in valid_hanchans:
|
||||
hanchan.get_playerdata(self.user)
|
||||
if since and since < hanchan.start:
|
||||
if since and hanchan.start < since:
|
||||
print(hanchan, "<", since, "no recalc")
|
||||
self.dan_points += hanchan.dan_points or 0
|
||||
self.kyu_points += hanchan.kyu_points or 0
|
||||
self.update_rank()
|
||||
@@ -495,19 +499,19 @@ class KyuDanRanking(models.Model):
|
||||
self.update_rank()
|
||||
hanchan.update_playerdata(self.user)
|
||||
hanchan.save(recalculate=False)
|
||||
self.won_hanchans += 1 if hanchan.placement == 1 else 0
|
||||
self.good_hanchans += 1 if hanchan.placement == 2 else 0
|
||||
self.last_hanchan_date = hanchan.start
|
||||
LOGGER.debug(
|
||||
'id: %(id)d, start: %(start)s, placement: %(placement)d, '
|
||||
'score: %(score)d, kyu points: %(kyu_points)d, dan points: '
|
||||
'%(dan_points)d, bonus points: %(bonus_points)d',
|
||||
{'id': hanchan.pk, 'start': hanchan.start,
|
||||
'placement': hanchan.placement, 'score': hanchan.game_score,
|
||||
'kyu_points': hanchan.kyu_points or 0,
|
||||
'dan_points': hanchan.dan_points or 0,
|
||||
'bonus_points': hanchan.bonus_points or 0}
|
||||
)
|
||||
self.won_hanchans += 1 if hanchan.placement == 1 else 0
|
||||
self.good_hanchans += 1 if hanchan.placement == 2 else 0
|
||||
self.last_hanchan_date = hanchan.start
|
||||
LOGGER.debug(
|
||||
'id: %(id)d, start: %(start)s, placement: %(placement)d, '
|
||||
'score: %(score)d, kyu points: %(kyu_points)d, dan points: '
|
||||
'%(dan_points)d, bonus points: %(bonus_points)d',
|
||||
{'id': hanchan.pk, 'start': hanchan.start,
|
||||
'placement': hanchan.placement, 'score': hanchan.game_score,
|
||||
'kyu_points': hanchan.kyu_points or 0,
|
||||
'dan_points': hanchan.dan_points or 0,
|
||||
'bonus_points': hanchan.bonus_points or 0}
|
||||
)
|
||||
self.save(force_update=True)
|
||||
|
||||
|
||||
@@ -564,6 +568,7 @@ class KyuDanRanking(models.Model):
|
||||
hanchan.kyu_points -= (self.kyu_points + hanchan.kyu_points)
|
||||
self.kyu_points += hanchan.kyu_points
|
||||
|
||||
|
||||
# TODO: Merkwürdige Methode die zwar funktioniert aber nicht sehr
|
||||
# aussagekräfig ist. Überarbeiten?
|
||||
def update_rank(self):
|
||||
|
||||
Reference in New Issue
Block a user