<s> from django import template <EOL> from task . models import Execution <EOL> register = template . Library ( ) <EOL> icons_mapping = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT:user>" : "<STR_LIT:user>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } <EOL> status_mapping = { <EOL> Execution . PENDING : [ "<STR_LIT:default>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> Execution . RUNNING : [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> Execution . SUCCESS : [ "<STR_LIT:success>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> Execution . FAILED : [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> Execution . ABORTED : [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> } <EOL> @ register . simple_tag <EOL> def model_icon ( model ) : <EOL> if not model in icons_mapping : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> return '<STR_LIT>' + icons_mapping [ model ] + '<STR_LIT>' <EOL> @ register . simple_tag <EOL> def execution_status ( status , caption = True ) : <EOL> if caption : <EOL> html = '<STR_LIT>' % tuple ( status_mapping [ status ] ) <EOL> else : <EOL> html = '<STR_LIT>' % tuple ( status_mapping [ status ] [ <NUM_LIT:0> : <NUM_LIT:2> ] ) <EOL> return html <EOL> @ register . filter <EOL> def lookup ( h , key ) : <EOL> try : <EOL> return h [ key ] <EOL> except KeyError : <EOL> return '<STR_LIT>' </s>
