<s> """<STR_LIT>""" <EOL> from coffin import template <EOL> from django . core . context_processors import csrf <EOL> from treeio . core . rendering import render_to_string <EOL> from jinja2 import contextfunction , Markup <EOL> from treeio . core . models import Object , Perspective <EOL> from treeio . core . conf import settings <EOL> register = template . Library ( ) <EOL> @ contextfunction <EOL> def user_block ( context ) : <EOL> """<STR_LIT>""" <EOL> request = context [ '<STR_LIT>' ] <EOL> user = request . user . profile <EOL> modules = user . get_perspective ( ) . get_modules ( ) <EOL> account = modules . filter ( name = '<STR_LIT>' ) <EOL> admin = modules . filter ( name = '<STR_LIT>' ) <EOL> if admin : <EOL> admin = admin [ <NUM_LIT:0> ] <EOL> response_format = '<STR_LIT:html>' <EOL> if '<STR_LIT>' in context : <EOL> response_format = context [ '<STR_LIT>' ] <EOL> trial = False <EOL> if getattr ( settings , '<STR_LIT>' ) == <NUM_LIT:3> : <EOL> trial = True <EOL> active = context . get ( '<STR_LIT>' , None ) <EOL> return Markup ( render_to_string ( '<STR_LIT>' , <EOL> { '<STR_LIT:user>' : user , <EOL> '<STR_LIT>' : account , <EOL> '<STR_LIT>' : admin , <EOL> '<STR_LIT>' : active , <EOL> '<STR_LIT>' : trial } , <EOL> response_format = response_format ) ) <EOL> register . object ( user_block ) <EOL> @ contextfunction <EOL> def demo_user ( context ) : <EOL> "<STR_LIT>" <EOL> response_format = '<STR_LIT:html>' <EOL> demo = getattr ( settings , '<STR_LIT>' , False ) <EOL> return Markup ( render_to_string ( '<STR_LIT>' , <EOL> { '<STR_LIT>' : demo } , <EOL> response_format = response_format ) ) <EOL> register . object ( demo_user ) <EOL> @ contextfunction <EOL> def core_perspective_switch ( context ) : <EOL> "<STR_LIT>" <EOL> response_format = '<STR_LIT:html>' <EOL> request = context [ '<STR_LIT>' ] <EOL> try : <EOL> user = request . user . profile <EOL> current = user . get_perspective ( ) <EOL> perspectives = Object . filter_by_request ( request , Perspective . objects ) <EOL> except : <EOL> current = None <EOL> perspectives = [ ] <EOL> context = { '<STR_LIT>' : current , '<STR_LIT>' : perspectives } <EOL> context . update ( csrf ( request ) ) <EOL> return Markup ( render_to_string ( '<STR_LIT>' , context , <EOL> response_format = response_format ) ) <EOL> register . object ( core_perspective_switch ) </s>
