<s> from django import template <EOL> from django . contrib . contenttypes . models import ContentType <EOL> from django . core . urlresolvers import reverse <EOL> register = template . Library ( ) <EOL> from voting . models import Vote <EOL> from issues . models import Issue , IssueContributor <EOL> @ register . inclusion_tag ( "<STR_LIT>" , takes_context = True ) <EOL> def show_issue ( context , issue ) : <EOL> extras = False <EOL> if issue . private or issue . sandbox or issue . model_project : <EOL> extras = True <EOL> return { '<STR_LIT>' : issue , '<STR_LIT>' : extras , '<STR_LIT>' : context [ '<STR_LIT>' ] } <EOL> @ register . simple_tag <EOL> def clear_search_url ( request ) : <EOL> getvars = request . GET . copy ( ) <EOL> if '<STR_LIT>' in getvars : <EOL> del getvars [ '<STR_LIT>' ] <EOL> if len ( getvars . keys ( ) ) > <NUM_LIT:0> : <EOL> return "<STR_LIT>" % ( request . path , getvars . urlencode ( ) ) <EOL> else : <EOL> return request . path <EOL> @ register . simple_tag <EOL> def persist_getvars ( request ) : <EOL> getvars = request . GET . copy ( ) <EOL> if len ( getvars . keys ( ) ) > <NUM_LIT:0> : <EOL> return "<STR_LIT>" % getvars . urlencode ( ) <EOL> return '<STR_LIT>' <EOL> @ register . simple_tag <EOL> def filter_url ( request , the_filter , the_value ) : <EOL> getvars = request . GET . copy ( ) <EOL> getvars [ the_filter ] = the_value <EOL> return "<STR_LIT>" % ( request . path , getvars . urlencode ( ) ) <EOL> @ register . simple_tag <EOL> def remove_filter_url ( request , the_filter ) : <EOL> getvars = request . GET . copy ( ) <EOL> del getvars [ the_filter ] <EOL> return "<STR_LIT>" % ( request . path , getvars . urlencode ( ) ) <EOL> @ register . simple_tag <EOL> def filter_link ( request , the_filter , the_value , the_text ) : <EOL> return '<STR_LIT>' % ( filter_url ( request , the_filter , the_value ) , the_text ) <EOL> @ register . filter <EOL> def truncatechar ( text , length ) : <EOL> if len ( text ) <= length : <EOL> return text <EOL> else : <EOL> return text [ : length ] + '<STR_LIT>' </s>
