V
V
vikholodov2018-08-30 16:16:22
Django
vikholodov, 2018-08-30 16:16:22

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

1 answer(s)
V
vikholodov, 2018-08-30
@vikholodov

Everything banal is simple, 0 is a string, aptel-moptel

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question