Files
zulip/zerver/views/digest.py
Tim Abbott 01ce58319d mypy: Fix most AnonymousUser type errors.
This commit fixes several mypy errors with Django stubs, by telling
mypy that we know in a given code path that the user is authenticated.
2021-07-24 14:55:46 -07:00

22 lines
761 B
Python

import time
from datetime import timedelta
from django.conf import settings
from django.http import HttpRequest, HttpResponse
from django.shortcuts import render
from django.utils.timezone import now as timezone_now
from zerver.decorator import zulip_login_required
from zerver.lib.digest import DIGEST_CUTOFF, get_digest_context
@zulip_login_required
def digest_page(request: HttpRequest) -> HttpResponse:
user_profile = request.user
assert user_profile.is_authenticated
cutoff = time.mktime((timezone_now() - timedelta(days=DIGEST_CUTOFF)).timetuple())
context = get_digest_context(user_profile, cutoff)
context.update(physical_address=settings.PHYSICAL_ADDRESS)
return render(request, "zerver/digest_base.html", context=context)