#NEWLINE# @ login_required #NEWLINE# def project_step_create_edit( request , project_slug , project_step_number = None ) : #NEWLINE# #INDENT# user = request . user #NEWLINE# project = get_object_or_404 ( Project , slug = project_slug ) #NEWLINE# if ( not project . is_editable ( request ) ) : #NEWLINE# #INDENT# return HttpResponseForbidden ( 'You are not the owner of this project.' ) #NEWLINE# #UNINDENT# if ( ( 'add' in request . path ) and ( project . steps . count ( ) >= 20 ) ) : #NEWLINE# #INDENT# messages . add_message ( request , messages . WARNING , 'This project already contains 20 steps.' ) #NEWLINE# return redirect ( 'project-detail' , project . slug ) #NEWLINE# #UNINDENT# if ( project_step_number is not None ) : #NEWLINE# #INDENT# project_step = get_object_or_404 ( ProjectStep , project = project , _order = project_step_number ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# project_step = ProjectStep ( project = project ) #NEWLINE# #UNINDENT# project_step_form = ProjectStepForm ( ( request . POST or None ) , instance = project_step ) #NEWLINE# if project_step_form . is_valid ( ) : #NEWLINE# #INDENT# project_step_form . save ( ) #NEWLINE# if project . is_published ( ) : #NEWLINE# #INDENT# action . send ( user , verb = 'updated' , action_object = project_step , target = project ) #NEWLINE# #UNINDENT# if ( 'save-add' in request . POST ) : #NEWLINE# #INDENT# redirect_args = ( 'project-step-create-edit' , project . slug ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# redirect_args = ( project , ) #NEWLINE# #UNINDENT# return redirect ( * redirect_args ) #NEWLINE# #UNINDENT# return render ( request , 'project/project_step_create_edit.html' , { #NEWLINE# #INDENT# 'project' : project , #NEWLINE# 'project_step' : project_step , #NEWLINE# 'project_step_form' : project_step_form , #NEWLINE# #UNINDENT# } )