Class: Renalware::Letters::BatchesController
- Inherits:
-
BaseController
- Object
- ApplicationController
- ApplicationController
- BaseController
- BaseController
- Renalware::Letters::BatchesController
- Includes:
- Concerns::Pageable
- Defined in:
- app/controllers/renalware/letters/batches_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
-
#index ⇒ Object
rubocop:enable Metrics/MethodLength.
-
#show ⇒ Object
rubocop:disable Metrics/MethodLength.
-
#status ⇒ Object
rubocop:disable Metrics/MethodLength.
Methods inherited from BaseController
Methods inherited from BaseController
Instance Method Details
#create ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/renalware/letters/batches_controller.rb', line 10 def create batch = create_unprocessed_batch_and_batch_items(ids_of_letters_to_batch_print) batch Printing::BatchPrintJob.perform_later(batch, current_user) respond_to do |format| format.js { render locals: { batch: batch } } end end |
#index ⇒ Object
rubocop:enable Metrics/MethodLength
60 61 62 63 64 |
# File 'app/controllers/renalware/letters/batches_controller.rb', line 60 def index batches = Batch.order(created_at: :desc) batches render locals: { batches: batches.page(page).per(per_page) } end |
#show ⇒ Object
rubocop:disable Metrics/MethodLength
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/renalware/letters/batches_controller.rb', line 40 def show batch = respond_to do |format| format.pdf do # Returns the PDF itself using path saved in the Batch - provided status is correct send_file( batch.filepath, type: "application/pdf", disposition: "inline", filename: "letter_batch_#{batch.id}.pdf" ) end format.html do # Returns a partial with a link to the compiled batch pdf render layout: false, locals: { batch: } end end end |
#status ⇒ Object
rubocop:disable Metrics/MethodLength
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/renalware/letters/batches_controller.rb', line 22 def status batch = (params[:batch_id]) respond_to do |format| format.json { render( status: :ok, json: { id: batch.id, status: batch.status, percent_complete: batch.percent_complete } ) } end end |