<s> from django import template <EOL> from users . models import UserToUserFollow <EOL> from django . core . urlresolvers import reverse <EOL> register = template . Library ( ) <EOL> @ register . inclusion_tag ( '<STR_LIT>' , takes_context = True ) <EOL> def follow_button ( context , followed ) : <EOL> user = context [ '<STR_LIT:user>' ] <EOL> button_class = "<STR_LIT>" <EOL> button_text = "<STR_LIT>" <EOL> post_url = "<STR_LIT>" <EOL> if user . is_authenticated ( ) : <EOL> if UserToUserFollow . actives . filter ( follower = user , followed = followed ) . count ( ) : <EOL> button_class += "<STR_LIT>" <EOL> button_text = "<STR_LIT>" <EOL> post_url = reverse ( '<STR_LIT>' , args = [ followed . id ] ) <EOL> else : <EOL> button_class += "<STR_LIT>" <EOL> post_url = reverse ( '<STR_LIT>' , args = [ followed . id ] ) <EOL> else : <EOL> button_class += "<STR_LIT>" <EOL> button = '<STR_LIT>' % ( button_class , button_text , post_url ) <EOL> return { <EOL> '<STR_LIT:user>' : user , <EOL> '<STR_LIT>' : post_url , <EOL> '<STR_LIT>' : button , <EOL> } </s>
