<s> """<STR_LIT>""" <EOL> from django . core . urlresolvers import reverse <EOL> from django import template <EOL> from django . utils . timezone import datetime , now , timedelta , utc <EOL> from . . models import Event , EventCategory <EOL> register = template . Library ( ) <EOL> @ register . filter <EOL> def get_week_URL ( date , day = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> if day < <NUM_LIT:1> : <EOL> day = <NUM_LIT:1> <EOL> date = datetime ( year = date . year , month = date . month , day = day , tzinfo = utc ) <EOL> return reverse ( '<STR_LIT>' , kwargs = { '<STR_LIT>' : date . isocalendar ( ) [ <NUM_LIT:0> ] , <EOL> '<STR_LIT>' : date . isocalendar ( ) [ <NUM_LIT:1> ] } ) <EOL> def _get_upcoming_events ( amount = <NUM_LIT:5> , category = None ) : <EOL> if not isinstance ( category , EventCategory ) : <EOL> category = None <EOL> return Event . objects . get_occurrences ( <EOL> now ( ) , now ( ) + timedelta ( days = <NUM_LIT> ) , category ) [ : amount ] <EOL> @ register . inclusion_tag ( '<STR_LIT>' ) <EOL> def render_upcoming_events ( event_amount = <NUM_LIT:5> , category = None ) : <EOL> """<STR_LIT>""" <EOL> return { <EOL> '<STR_LIT>' : _get_upcoming_events ( <EOL> amount = event_amount , category = category ) , <EOL> } <EOL> @ register . assignment_tag <EOL> def get_upcoming_events ( amount = <NUM_LIT:5> , category = None ) : <EOL> """<STR_LIT>""" <EOL> return _get_upcoming_events ( amount = amount , category = category ) </s>
