app/controllers/enrollment_controller.rb
# updates the enrollment status - using a defined set of commands. The commands
# that are allowed are depending on the current enrollment status.
updates the enrollment status - using a defined set of commands. The commands
that are allowed are depending on the current enrollment status.
updates the enrollment status - using a defined set of commands . The commands that are allowed are depending on the current enrollment status .
def update
    enrollment = Enrollment.find(params[:id])
    @privs = enrollment.privileges(@user)
    case params[:command]
    when "drop"
      result = enrollment.set_dropped(@user)
      flash[:notice] = "#{enrollment.participant.full_name} was dropped."
      redirect_to enrollments_path(:id => enrollment.contract_id) and return
    when "cancel"
      result = enrollment.set_closed(Enrollment::COMPLETION_CANCELED, @user)
    when "fulfill"
      result = enrollment.set_closed(Enrollment::COMPLETION_FULFILLED, @user)
    when "approve"
      result = enrollment.set_active(@user)
    when "student","instructor"
      enrollment.set_role(params[:command], @user)
    end
    enrollment.reload
    render :partial => 'status_update', :object => enrollment, :locals => {:editable => true}
  rescue TinyException => e
    redir_error(TinyException::SECURITYHACK, @user)
  end
def update enrollment = Enrollment . find ( params [ :id ] ) @privs = enrollment . privileges ( @user ) case params [ :command ] when "drop" result = enrollment . set_dropped ( @user ) flash [ :notice ] = "#{enrollment.participant.full_name} was dropped." redirect_to enrollments_path ( :id => enrollment . contract_id ) and return when "cancel" result = enrollment . set_closed ( Enrollment :: COMPLETION_CANCELED , @user ) when "fulfill" result = enrollment . set_closed ( Enrollment :: COMPLETION_FULFILLED , @user ) when "approve" result = enrollment . set_active ( @user ) when "student" , "instructor" enrollment . set_role ( params [ :command ] , @user ) end enrollment . reload render :partial => 'status_update' , :object => enrollment , :locals => { :editable => true } rescue TinyException => e redir_error ( TinyException :: SECURITYHACK , @user ) end
updates the enrollment status - using a defined set of commands.
updates the enrollment status - using a defined set of commands .