예제 #1
0
def add_featured_live_thread(controller):
    """If we have a live thread featured, display it on the homepage."""
    # Not on front page
    if not isinstance(c.site, DefaultSR):
        return None

    # Not on first page of front page
    if getattr(controller, 'listing_obj') and controller.listing_obj.prev:
        return None

    featured_event = get_featured_event()
    if not featured_event:
        return None

    return pages.LiveUpdateHappeningNowBar(event=featured_event)
def add_featured_live_thread(controller):
    """If we have a live thread featured, display it on the homepage."""
    if not feature.is_enabled('live_happening_now'):
        return None

    # Not on front page
    if not isinstance(c.site, DefaultSR):
        return None

    # Not on first page of front page
    if getattr(controller, 'listing_obj') and controller.listing_obj.prev:
        return None

    event_id = NamedGlobals.get(HAPPENING_NOW_KEY, None)
    if not event_id:
        return None

    try:
        event = LiveUpdateEvent._byID(event_id)
    except NotFound:
        return None
    else:
        return pages.LiveUpdateHappeningNowBar(event=event)