Answer the question
In order to leave comments, you need to log in
Why is it always False?
Hai.
Something brains absolutely none today, I can’t understand user.userprofile.email_notification, i.e. frequency == 0, but the send variable is still False on output, which would contradict one of the checks. Where did I go wrong?
def send_html_email(**kwargs):
''' Отправка email '''
context = kwargs
user = User.objects.get(email=kwargs['email'])
frequency = user.userprofile.email_notification
send = False
if kwargs.get('notifications_rules_except'):
send = True
if frequency not in ['na', 0]:
if not user.userprofile.last_notification:
send = True
else:
if datetime.now() - timedelta(hours=int(frequency)) <= user.userprofile.last_notification.replace(tzinfo=None):
send = True
if frequency == 0:
send = True
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question