Пример #1
0
def front_page_banner(request):
    now = timezone.now()
    campaigns = BannerCampaign.at(now)
    slots = (BannerTimeslot.objects
             .filter(campaign__in=campaigns)
             .filter(day=now.weekday(),
                     start_time__lte=now,
                     end_time__gt=now))
    return render(
        request,
        'website/banners/front_page.html',
        {
            'banners': [slot.campaign.banner for slot in slots]
        })
Пример #2
0
def front_page_banner(request, block_id=None):
    """
    Renders the current front page banner rotation.

    """
    now = timezone.now()
    campaigns = BannerCampaign.at(now)
    slots = (BannerTimeslot.objects
             .filter(campaign__in=campaigns)
             .filter(day=now.isoweekday(),
                     start_time__lte=now,
                     end_time__gt=now))
    return render(
        request,
        'website/banners/front_page.html',
        {
            'banners': [slot.campaign.banner for slot in slots]
        })