def get_sidebar_announcements_context(request, objects):
 must_show_announcement = False
 announcements = []
 if (SIDEBAR_COOKIE_NAME in request.COOKIES):
  try:
   is_sidebar_open = bool(int(request.COOKIES[SIDEBAR_COOKIE_NAME]))
  except ValueError:
   is_sidebar_open = True
  request.session['is_sidebar_open'] = is_sidebar_open
 else:
  is_sidebar_open = request.session.get('is_sidebar_open', True)
 for item in objects:
  announcement = item.get_announcement(request.user)
  if (announcement is None):
   continue
  announcements.append(announcement)
  if request.user.is_anonymous:
   continue
  ann_mtime = dateformat.format(announcement.modified_on, 'U')
  stored_mtime = request.session.get(announcement.virtual_path, None)
  if (ann_mtime != stored_mtime):
   must_show_announcement = True
   request.session[announcement.virtual_path] = ann_mtime
 ctx = {'announcements': announcements, 'is_sidebar_open': (must_show_announcement or is_sidebar_open), 'has_sidebar': (len(announcements) > 0)}
 return ctx

def get_sidebar_announcements_context ( request , objects ) : must_show_announcement = False announcements = [ ] if ( SIDEBAR_COOKIE_NAME in request . COOKIES ) : try : is_sidebar_open = bool ( int ( request . COOKIES [ SIDEBAR_COOKIE_NAME ] ) ) except ValueError : is_sidebar_open = True request . session [ 'is_sidebar_open' ] = is_sidebar_open else : is_sidebar_open = request . session . get ( 'is_sidebar_open' , True ) for item in objects : announcement = item . get_announcement ( request . user ) if ( announcement is None ) : continue announcements . append ( announcement ) if request . user . is_anonymous : continue ann_mtime = dateformat . format ( announcement . modified_on , 'U' ) stored_mtime = request . session . get ( announcement . virtual_path , None ) if ( ann_mtime != stored_mtime ) : must_show_announcement = True request . session [ announcement . virtual_path ] = ann_mtime ctx = { 'announcements' : announcements , 'is_sidebar_open' : ( must_show_announcement or is_sidebar_open ) , 'has_sidebar' : ( len ( announcements ) > 0 ) } return ctx
return the announcements context for the browser pages sidebar .