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

      def show
        @workup = DonorWorkup.for_patient(@patient).first_or_initialize

        redirect_to edit_patient_transplants_donor_workup_path(@patient) if @workup.new_record?
      end

      def edit
        @workup = DonorWorkup.for_patient(@patient).first_or_initialize
      end

      def update
        @workup = DonorWorkup.for_patient(@patient).first_or_initialize

        if @workup.update_attributes(workup_params)
          redirect_to patient_transplants_donor_workup_path(@patient)
        else
          render :edit
        end
      end

      private

      def workup_params
        document_attributes = params.require(:transplants_donor_workup)
          .fetch(:document, nil).try(:permit!)
        params.require(:transplants_donor_workup).permit.merge(document: document_attributes)
      end
    end
  end
end<commit_msg>Added missing notices for donor_workups_controller.<commit_after>module Renalware
  module Transplants
    class DonorWorkupsController < BaseController
      before_filter :load_patient

      def show
        @workup = DonorWorkup.for_patient(@patient).first_or_initialize

        redirect_to edit_patient_transplants_donor_workup_path(@patient) if @workup.new_record?
      end

      def edit
        @workup = DonorWorkup.for_patient(@patient).first_or_initialize
      end

      def update
        @workup = DonorWorkup.for_patient(@patient).first_or_initialize

        if @workup.update_attributes(workup_params)
          redirect_to patient_transplants_donor_workup_path(@patient),
            notice: t(".success", model_name: "donor work up")
        else
          flash[:error] = t(".failed", model_name: "donor work up")
          render :edit
        end
      end

      private

      def workup_params
        document_attributes = params.require(:transplants_donor_workup)
          .fetch(:document, nil).try(:permit!)
        params.require(:transplants_donor_workup).permit.merge(document: document_attributes)
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.07096474953617811, 'fraction_numerical': 0.0, 'mean_word_length': 3.0018552875695734, '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': '6021755', 'n_tokens_mistral': 639, 'n_tokens_neox': 612, 'n_words': 113}