<s> from django . utils import timezone <EOL> from django . conf import settings <EOL> from django . contrib . sites . models import get_current_site <EOL> from django . core . cache import cache <EOL> from opps . containers . models import Container <EOL> from . models import Channel <EOL> def channel_context ( request ) : <EOL> """<STR_LIT>""" <EOL> site = get_current_site ( request ) <EOL> if settings . OPPS_MENU : <EOL> opps_menu = cache . get ( '<STR_LIT>' ) <EOL> if not opps_menu : <EOL> extra_lookups = { } <EOL> if settings . OPPS_MENU_ONLY_WITH_PUBLISHED_CONTAINERS : <EOL> extra_lookups = Container . objects . get_all_published_lookups ( "<STR_LIT>" ) <EOL> opps_menu = [ channel for channel in Channel . objects . filter ( <EOL> site = site , <EOL> date_available__lte = timezone . now ( ) , <EOL> published = True , <EOL> show_in_menu = True , <EOL> ** extra_lookups ) . distinct ( ) . order_by ( '<STR_LIT>' ) ] <EOL> cache . set ( '<STR_LIT>' , opps_menu , settings . OPPS_CACHE_EXPIRE ) <EOL> else : <EOL> opps_menu = [ ] <EOL> return { '<STR_LIT>' : opps_menu , <EOL> '<STR_LIT>' : settings . OPPS_CHANNEL_CONF , <EOL> '<STR_LIT>' : site } </s>
