#NEWLINE# def index( request , tag = None ) : #NEWLINE# #INDENT# query = None #NEWLINE# if tag : #NEWLINE# #INDENT# tag = Tag . objects . get ( slug = tag ) #NEWLINE# if ( query is None ) : #NEWLINE# #INDENT# query = Thread . objects . all ( ) . order_by ( '-updated' ) . filter ( tag = tag ) . filter ( ref = None ) #NEWLINE# #UNINDENT# tags = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( query is None ) : #NEWLINE# #INDENT# query = Thread . objects . all ( ) . order_by ( '-updated' ) . filter ( ref = None ) #NEWLINE# #UNINDENT# tags = None #NEWLINE# if ( tags is not None ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# tags = Tag . objects . all ( ) . order_by ( '-updated' ) #NEWLINE# #UNINDENT# #UNINDENT# paginator = Paginator ( query , 10 ) #NEWLINE# page = request . GET . get ( 'page' , 1 ) #NEWLINE# try : #NEWLINE# #INDENT# threads = paginator . page ( page ) #NEWLINE# #UNINDENT# except PageNotAnInteger : #NEWLINE# #INDENT# threads = paginator . page ( 1 ) #NEWLINE# #UNINDENT# except EmptyPage : #NEWLINE# #INDENT# threads = paginator . page ( paginator . num_pages ) #NEWLINE# #UNINDENT# if ( len ( threads . paginator . page_range ) > 10 ) : #NEWLINE# #INDENT# page_range = [ ] #NEWLINE# page_range . append ( 1 ) #NEWLINE# head = False #NEWLINE# foot = False #NEWLINE# if ( ( ( threads . number - 4 ) > 2 ) and ( ( threads . number + 4 ) < threads . paginator . num_pages ) ) : #NEWLINE# #INDENT# start_page = ( threads . number - 4 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( threads . number + 4 ) >= threads . paginator . num_pages ) : #NEWLINE# #INDENT# start_page = ( threads . paginator . num_pages - 8 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# start_page = 2 #NEWLINE# #UNINDENT# #UNINDENT# end_page = ( start_page + 7 ) #NEWLINE# if ( start_page > 2 ) : #NEWLINE# #INDENT# head = True #NEWLINE# page_range . append ( False ) #NEWLINE# #UNINDENT# for i in range ( 0 , 8 ) : #NEWLINE# #INDENT# page_range . append ( ( start_page + i ) ) #NEWLINE# #UNINDENT# if ( start_page < ( threads . paginator . num_pages - 8 ) ) : #NEWLINE# #INDENT# foot = True #NEWLINE# page_range . append ( False ) #NEWLINE# #UNINDENT# page_range . append ( threads . paginator . num_pages ) #NEWLINE# threads . paginator . page_range_list = page_range #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# threads . paginator . page_range_list = threads . paginator . page_range #NEWLINE# #UNINDENT# updated_tags = None #NEWLINE# if ( updated_tags is not None ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if tags : #NEWLINE# #INDENT# updated_tags = tags [ 0 : 20 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# updated_tags = Tag . objects . all ( ) . order_by ( '-updated' ) [ : 20 ] #NEWLINE# #UNINDENT# #UNINDENT# form = ThreadForm ( ) #NEWLINE# values = { #NEWLINE# #INDENT# 'threads' : threads , #NEWLINE# 'tags' : tags , #NEWLINE# 'updated_tags' : updated_tags , #NEWLINE# 'tag' : tag , #NEWLINE# 'form' : form , #NEWLINE# #UNINDENT# } #NEWLINE# return render_to_response ( 'board/threads.html' , values , context_instance = RequestContext ( request ) )