class ClassImportsController
Public Instance Methods
Source
# File app/controllers/class_imports_controller.rb, line 102 def approve @class_import.reviewed_by_user_ids << current_user.id @class_import.reviewed_at << Time.zone.now @class_import.committing! @class_import.changesets.not_from_file.ready_for_review.update_all( status: :committing ) if @class_import.changesets.from_file.ready_for_review.any? @class_import.commit_changesets( @class_import.changesets.from_file.ready_for_review ) elsif @class_import.changesets.cancelled.any? @class_import.update_columns( status: :partially_processed, processed_at: Time.zone.now ) @class_import.postprocess_rows! else @class_import.update_columns( status: :processed, processed_at: Time.zone.now ) @class_import.postprocess_rows! end redirect_to imports_path, flash: { info: "Import started" } end
Source
# File app/controllers/class_imports_controller.rb, line 132 def cancel @class_import.reviewed_by_user_ids << current_user.id @class_import.reviewed_at << Time.zone.now # some changesets were processed after first review, but the second review was cancelled if @class_import.changesets.processed.any? @class_import.update_columns( processed_at: Time.zone.now, status: :partially_processed ) @class_import.save! @class_import.changesets.from_file.ready_for_review.update_all( status: :cancelled ) @class_import.changesets.not_from_file.ready_for_review.update_all( status: :committing ) @class_import.postprocess_rows! redirect_to imports_path, flash: { success: "Import partially completed" } else @class_import.update!(status: :cancelled) @class_import.changesets.each(&:cancelled!) redirect_to imports_path, flash: { success: "Import cancelled" } end end
Source
# File app/controllers/class_imports_controller.rb, line 20 def create @class_import = authorize ClassImport.new( academic_year: @academic_year, location: @location, team: current_team, uploaded_by: current_user, year_groups: @draft_import.year_groups, **class_import_params ) if @class_import.invalid? render :new, status: :unprocessable_content and return end @class_import.save! ProcessImportJob.perform_later(@class_import) redirect_to imports_path, flash: { success: "Import processing started" } end
Source
# File app/controllers/class_imports_controller.rb, line 94 def imported_records render template: "imports/imported_records", layout: "full", locals: { import: @class_import } end
Source
# File app/controllers/class_imports_controller.rb, line 16 def new @class_import = authorize ClassImport.new(team: current_team) end
Source
# File app/controllers/class_imports_controller.rb, line 86 def re_review render template: "imports/re_review", layout: "full", locals: { import: @class_import } end
Source
# File app/controllers/class_imports_controller.rb, line 41 def show if @class_import.rows_are_invalid? || @class_import.changesets_are_invalid? @class_import.load_serialized_errors!(limit: error_rows_limit) end set_review_records if @class_import.in_review? if @class_import.in_re_review? redirect_to re_review_class_import_path(@class_import) and return end if @class_import.processed? || @class_import.partially_processed? @pagy, @patients = pagy(@class_import.patients.includes(:school)) @duplicates = @patients.with_pending_changes_for_team(team: current_team).distinct @issues_text = @duplicates.each_with_object({}) do |patient, hash| changeset = @class_import.changesets.find_by(patient_id: patient.id) issue_groups = helpers.issue_categories_for(patient.pending_changes.keys) hash[patient.full_name] = if changeset&.matched_on_nhs_number "Matched on NHS number. #{issue_groups.to_sentence.capitalize}" + (issue_groups.size == 1 ? " does not match." : " do not match.") else "Possible match found. Review and confirm." end end @nhs_discrepancies = @class_import.changesets.includes(:patient).nhs_number_discrepancies @cancelled = @class_import.changesets.from_file.cancelled end render template: "imports/show", layout: "full", locals: { import: @class_import } end