diff --git a/nalodeni/auth.py b/nalodeni/auth.py index f2179b0..bef8659 100644 --- a/nalodeni/auth.py +++ b/nalodeni/auth.py @@ -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]