#NEWLINE# @ register . inclusion_tag ( 'cbv/includes/nav.html' ) #NEWLINE# def nav( version , module = None , klass = None ) : #NEWLINE# #INDENT# other_versions = ProjectVersion . objects . filter ( project = version . project ) . exclude ( pk = version . pk ) #NEWLINE# context = { #NEWLINE# #INDENT# 'version' : klass , #NEWLINE# #UNINDENT# } #NEWLINE# if module : #NEWLINE# #INDENT# context [ 'this_module' ] = module #NEWLINE# if klass : #NEWLINE# #INDENT# context [ 'this_klass' ] = klass #NEWLINE# other_versions_of_klass = Klass . objects . filter ( name = klass . name , module__project_version__in = other_versions ) #NEWLINE# other_versions_of_klass_dict = { x . module . project_version : x for x in other_versions_of_klass } #NEWLINE# for other_version in other_versions : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# other_klass = other_versions_of_klass_dict [ other_version ] #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# other_version . url = other_klass . get_absolute_url ( ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# context [ 'other_versions' ] = other_versions #NEWLINE# return context