zulip/zerver/views/digest.py
Steve Howell e31326c823 refactor: Extract get_digest_context.
This eliminates the union type and boolean parameter,
and it makes it a bit easier to migrate to a
bulk-get approach.
2020-11-05 09:36:59 -08:00

21 lines
720 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
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)