<commit_before>module Renalware
  module Transplants
    class DonorOperationsController < BaseController
      before_filter :load_patient

      def show
        @donor_operation = DonorOperation.for_patient(@patient).find(params[:id])
      end

      def new
        @donor_operation = DonorOperation.new
      end

      def create
        @donor_operation = DonorOperation.new(patient: @patient)
        @donor_operation.attributes = operation_params

        if @donor_operation.save
          redirect_to patient_transplants_donor_dashboard_path(@patient)
        else
          render :new
        end
      end

      def edit
        @donor_operation = DonorOperation.for_patient(@patient).find(params[:id])
      end

      def update
        @donor_operation = DonorOperation.for_patient(@patient).find(params[:id])
        @donor_operation.attributes = operation_params

        if @donor_operation.save
          redirect_to patient_transplants_donor_dashboard_path(@patient)
        else
          render :edit
        end
      end

      protected

      def operation_params
        params.require(:transplants_donor_operation)
          .permit(attributes)
          .merge(document: document_attributes)
      end

      def attributes
        [
          :performed_on, :notes,
          :anaesthetist, :donor_splenectomy_peri_or_post_operatively, :kidney_side,
          :nephrectomy_type, :nephrectomy_type_other, :operating_surgeon,
          document: []
        ]
      end

      def document_attributes
        params.require(:transplants_donor_operation)
         .fetch(:document, nil).try(:permit!)
      end
    end
  end
end
<commit_msg>Added missing notices for donor_operations_controller.<commit_after>module Renalware
  module Transplants
    class DonorOperationsController < BaseController
      before_filter :load_patient

      def show
        @donor_operation = DonorOperation.for_patient(@patient).find(params[:id])
      end

      def new
        @donor_operation = DonorOperation.new
      end

      def create
        @donor_operation = DonorOperation.new(patient: @patient)
        @donor_operation.attributes = operation_params

        if @donor_operation.save
          redirect_to patient_transplants_donor_dashboard_path(@patient),
            notice: t(".success", model_name: "donor operation")
        else
          flash[:error] = t(".failed", model_name: "donor operation")
          render :new
        end
      end

      def edit
        @donor_operation = DonorOperation.for_patient(@patient).find(params[:id])
      end

      def update
        @donor_operation = DonorOperation.for_patient(@patient).find(params[:id])
        @donor_operation.attributes = operation_params

        if @donor_operation.save
          redirect_to patient_transplants_donor_dashboard_path(@patient),
            notice: t(".success", model_name: "donor operation")
        else
          flash[:error] = t(".failed", model_name: "donor operation")
          render :edit
        end
      end

      protected

      def operation_params
        params.require(:transplants_donor_operation)
          .permit(attributes)
          .merge(document: document_attributes)
      end

      def attributes
        [
          :performed_on, :notes,
          :anaesthetist, :donor_splenectomy_peri_or_post_operatively, :kidney_side,
          :nephrectomy_type, :nephrectomy_type_other, :operating_surgeon,
          document: []
        ]
      end

      def document_attributes
        params.require(:transplants_donor_operation)
         .fetch(:document, nil).try(:permit!)
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.07633378932968536, 'fraction_numerical': 0.0, 'mean_word_length': 2.4686907020872866, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5396604', 'n_tokens_mistral': 1041, 'n_tokens_neox': 1002, 'n_words': 192}