#NEWLINE# @ handle_response_format #NEWLINE# @ treeio_login_required #NEWLINE# @ module_admin_required ( ) #NEWLINE# def perspective_edit( request , perspective_id , response_format = 'html' ) : #NEWLINE# #INDENT# 'Perspective edit' #NEWLINE# perspective = get_object_or_404 ( Perspective , pk = perspective_id ) #NEWLINE# other_perspectives = Perspective . objects . filter ( trash = False ) . exclude ( id = perspective_id ) #NEWLINE# admin_module = Module . objects . filter ( name = 'treeio.core' ) [ 0 ] #NEWLINE# if request . POST : #NEWLINE# #INDENT# if ( 'cancel' not in request . POST ) : #NEWLINE# #INDENT# form = PerspectiveForm ( request . user . profile , request . POST , instance = perspective ) #NEWLINE# if form . is_valid ( ) : #NEWLINE# #INDENT# perspective = form . save ( ) #NEWLINE# modules = perspective . modules . all ( ) #NEWLINE# if ( modules and ( admin_module not in modules ) ) : #NEWLINE# #INDENT# if ( not other_perspectives . filter ( ( Q ( modules = admin_module ) | Q ( modules__isnull = True ) ) ) ) : #NEWLINE# #INDENT# perspective . modules . add ( admin_module ) #NEWLINE# request . session [ 'message' ] = _ ( 'This is your only Perspective with Administration module. You would be locked out!' ) #NEWLINE# #UNINDENT# #UNINDENT# return HttpResponseRedirect ( reverse ( 'core_admin_perspective_view' , args = [ perspective . id ] ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# return HttpResponseRedirect ( reverse ( 'core_admin_perspective_view' , args = [ perspective . id ] ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# form = PerspectiveForm ( request . user . profile , instance = perspective ) #NEWLINE# #UNINDENT# request . session . pop ( 'message' , '' ) #NEWLINE# return render_to_response ( 'core/administration/perspective_edit' , { #NEWLINE# #INDENT# 'perspective' : perspective , #NEWLINE# 'form' : form , #NEWLINE# #UNINDENT# } , context_instance = RequestContext ( request ) , response_format = response_format )