<s> from django . conf import settings <EOL> from django . contrib . admin . templatetags . admin_modify import submit_row <EOL> from django . contrib . admin . views . main import SEARCH_VAR <EOL> from django . template import Library <EOL> from ralph . admin . helpers import ( <EOL> get_content_type_for_model , <EOL> get_field_by_relation_path , <EOL> get_value_by_relation_path <EOL> ) <EOL> from ralph . lib . transitions . models import TransitionsHistory <EOL> register = Library ( ) <EOL> SENTRY_ENABLED = getattr ( settings , '<STR_LIT>' ) <EOL> SENTRY_JS_DSN = getattr ( settings , '<STR_LIT>' ) <EOL> SENTRY_JS_CONFIG = getattr ( settings , '<STR_LIT>' ) <EOL> @ register . inclusion_tag ( <EOL> '<STR_LIT>' , takes_context = True <EOL> ) <EOL> def download_attachment ( context ) : <EOL> return { <EOL> '<STR_LIT>' : context . request . session . pop ( <EOL> '<STR_LIT>' , None <EOL> ) <EOL> } <EOL> @ register . inclusion_tag ( '<STR_LIT>' , takes_context = True ) <EOL> def views_tabs ( context , views , name = None , obj = None ) : <EOL> """<STR_LIT>""" <EOL> result = [ ] <EOL> if obj : <EOL> for view in views : <EOL> codename = '<STR_LIT>' . format ( <EOL> obj . _meta . app_label , view . permision_codename <EOL> ) <EOL> if context . request . user . has_perm ( codename ) : <EOL> result . append ( view ) <EOL> else : <EOL> result = views <EOL> return { '<STR_LIT>' : result , '<STR_LIT:name>' : name , '<STR_LIT:object>' : obj } <EOL> @ register . inclusion_tag ( '<STR_LIT>' , takes_context = True ) <EOL> def contextual_search_form ( context , search_url , search_fields , verbose_name ) : <EOL> context . update ( { <EOL> '<STR_LIT>' : search_url , <EOL> '<STR_LIT>' : search_fields , <EOL> '<STR_LIT>' : SEARCH_VAR , <EOL> '<STR_LIT>' : verbose_name . lower ( ) , <EOL> } ) <EOL> return context <EOL> @ register . inclusion_tag ( '<STR_LIT>' , takes_context = True ) <EOL> def ralph_submit_row ( context ) : <EOL> """<STR_LIT>""" <EOL> ctx = submit_row ( context ) <EOL> ctx [ '<STR_LIT>' ] = context . get ( '<STR_LIT>' , None ) <EOL> ctx [ '<STR_LIT>' ] = context . get ( '<STR_LIT>' , None ) <EOL> return ctx <EOL> @ register . filter <EOL> def get_attr ( obj , attr ) : <EOL> """<STR_LIT>""" <EOL> return get_value_by_relation_path ( obj , attr ) <EOL> @ register . filter <EOL> def get_verbose_name ( obj , name ) : <EOL> """<STR_LIT>""" <EOL> return get_field_by_relation_path ( obj , name ) . verbose_name <EOL> @ register . inclusion_tag ( '<STR_LIT>' ) <EOL> def transition_history ( obj ) : <EOL> """<STR_LIT>""" <EOL> content_type = get_content_type_for_model ( obj ) <EOL> history = TransitionsHistory . objects . filter ( <EOL> content_type = content_type , object_id = obj . pk <EOL> ) . select_related ( '<STR_LIT>' ) . order_by ( '<STR_LIT>' ) <EOL> return { <EOL> '<STR_LIT>' : history , <EOL> '<STR_LIT>' : True <EOL> } <EOL> @ register . inclusion_tag ( '<STR_LIT>' ) <EOL> def raven_js ( ) : <EOL> return { <EOL> '<STR_LIT>' : SENTRY_ENABLED , <EOL> '<STR_LIT>' : SENTRY_JS_DSN , <EOL> '<STR_LIT>' : SENTRY_JS_CONFIG <EOL> } </s>
