Sha256: 7fafc7ae5b187e8729b2641696c12067b401adda8165f2f4980c76c2dad5ae56

Contents?: true

Size: 1.19 KB

Versions: 140

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

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

140 entries across 140 versions & 1 rubygems

Version Path
renalware-core-2.0.82 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.81 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.80 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.79 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.78 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.77 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.76 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.75 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.74 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.73 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.72 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.71 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.70 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.69 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.68 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.67 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.64 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.63 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.62 app/controllers/renalware/transplants/donor_stages_controller.rb
renalware-core-2.0.61 app/controllers/renalware/transplants/donor_stages_controller.rb