FIX: chyba stringu v nastaveni NALODENI_TOKEN_VALID_SEC

This commit is contained in:
Jarmil 2019-12-09 12:45:45 +01:00
parent 63d8af6031
commit 27ce8e204b
1 changed files with 12 additions and 4 deletions

View File

@ -188,10 +188,19 @@ def sendRegisterTokenReg(rt):
rt.etStamp = datetime.now()
rt.save()
# TODO: tohle je jen QuickFix. Validovat zde settings je dost pozde,
# Melo by spadnout pri startu: predelat ten bordylek v main/settings.py
# pote predelat vsude kde se pouziva konstrukce int(TOKEN_VALID_SEC)
try:
token_validity = int(appSettings.TOKEN_VALID_SEC)
except:
token_validity = 60*60*24*3
logger.error("invalid seting NALODENI_TOKEN_VALID_SEC - should be string")
word_days = "dní"
if appSettings.TOKEN_VALID_SEC < 60*60*24*5:
if token_validity < 60*60*24*5:
word_days = "dny"
if appSettings.TOKEN_VALID_SEC <= 60*60*24*1:
if token_validity <= 60*60*24*1:
word_days = "den"
emailBody = """\
@ -207,13 +216,12 @@ Odkaz platí {days} {word}.
S pozdravem
Piráti
"""
send_mail_safe(
'Piráti - nalodění - registrační odkaz',
emailBody.format(
emailToken=emailToken,
baseUrl=appSettings.BASE_URL,
days=int(math.floor(appSettings.TOKEN_VALID_SEC / (60*60*24))),
days=int(math.floor(token_validity / (60*60*24))),
word=word_days),
"nalodeni@pirati.cz",
[rt.email]