diff --git a/plugins/printer/app/controllers/printer_jobs_controller.rb b/plugins/printer/app/controllers/printer_jobs_controller.rb index 17333fb5..37c864e9 100644 --- a/plugins/printer/app/controllers/printer_jobs_controller.rb +++ b/plugins/printer/app/controllers/printer_jobs_controller.rb @@ -30,6 +30,14 @@ class PrinterJobsController < ApplicationController @job = PrinterJob.find(params[:id]) end + def requeue + job = PrinterJob.find(params[:id]) + job = PrinterJob.create! order: job.order, document: job.document, created_by: current_user + job.add_update! 'requeued' + PrinterChannel.broadcast_unfinished + redirect_to printer_jobs_path, notice: t('.notice') + end + def document job = PrinterJob.find(params[:id]) send_order_pdf job.order, job.document diff --git a/plugins/printer/app/views/printer_jobs/_jobs.html.haml b/plugins/printer/app/views/printer_jobs/_jobs.html.haml index 5c197342..d51292cb 100644 --- a/plugins/printer/app/views/printer_jobs/_jobs.html.haml +++ b/plugins/printer/app/views/printer_jobs/_jobs.html.haml @@ -11,6 +11,7 @@ %th= heading_helper(PrinterJob, :document) %th= heading_helper(PrinterJob, :last_update_state) %th= heading_helper(PrinterJob, :finished_at) + %th %tbody - @finished_jobs.each do |j| %tr @@ -20,3 +21,4 @@ %td= link_to j.document, document_printer_job_path(j) %td= j.last_update_state %td= format_time j.finished_at + %td= link_to t('.requeue'), requeue_printer_job_path(j), method: :post, class: 'btn btn-mini' diff --git a/plugins/printer/app/views/printer_jobs/show.html.haml b/plugins/printer/app/views/printer_jobs/show.html.haml index 2d023381..862df886 100644 --- a/plugins/printer/app/views/printer_jobs/show.html.haml +++ b/plugins/printer/app/views/printer_jobs/show.html.haml @@ -1,5 +1,8 @@ - title t('.title', id: @job.id) +- content_for :actionbar do + = link_to t('.requeue'), requeue_printer_job_path(@job), method: :post, class: 'btn' + %p %b= heading_helper(PrinterJob, :created_by) + ':' = show_user @job.created_by diff --git a/plugins/printer/config/locales/en.yml b/plugins/printer/config/locales/en.yml index 6a5a8474..13233902 100644 --- a/plugins/printer/config/locales/en.yml +++ b/plugins/printer/config/locales/en.yml @@ -26,7 +26,7 @@ en: finished: Finished pending: Pending queued: Waiting for order to close + requeued: Requeued title: Printer jobs show: title: Printer job %{id} - diff --git a/plugins/printer/config/routes.rb b/plugins/printer/config/routes.rb index 5b1a4784..c81fc786 100644 --- a/plugins/printer/config/routes.rb +++ b/plugins/printer/config/routes.rb @@ -5,6 +5,7 @@ Rails.application.routes.draw do end resources :printer_jobs, only: [:index, :create, :show, :destroy] do + post :requeue, on: :member get :document, on: :member end end