Sha256: 763c0187773491ea43f966b95d4b8e96cb1482f9d61541d1cc56b63ca447ff24

Contents?: true

Size: 1.16 KB

Versions: 27

Compression:

Stored size: 1.16 KB

Contents

require_dependency "renalware/transplants"
require_dependency "renalware/transplants/base_controller"

module Renalware
  module Transplants
    class DonorStagesController < BaseController
      def new
        stage = DonorStage.new(patient: patient)
        authorize stage
        render locals: {
          patient: patient,
          stage: stage
        }
      end

      def create
        authorize donor_stage
        result = CreateDonorStage.new(patient: patient, options: donor_stage_params).call
        if result.success?
          redirect_to patient_transplants_donor_dashboard_path(patient),
                      notice: t(".success", model_name: "donor stage")
        else
          render :new, locals: {
            patient: patient,
            stage: result.object
          }
        end
      end

      private

      def donor_stage
        @donor_stage ||= DonorStage.for_patient(patient).first_or_initialize
      end

      def donor_stage_params
        params
          .require(:donor_stage)
          .permit(:started_on, :stage_position_id, :stage_status_id, :notes)
          .to_h
          .merge(by: current_user)
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
renalware-core-2.0.16 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.15 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.14 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.13 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.12 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.11 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.9 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.8 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.7 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.5 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.4 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.3 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.2 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.1 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.0 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.0.pre.rc13 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.0.pre.rc11 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.0.pre.rc10 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.0.pre.rc9 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.0.pre.rc8 app/controllers/renalware/transplants/donor_stages_controller.rb