Run rubocop --fix-layout and remove encoding comments
This commit is contained in:
parent
fa63e6e81d
commit
ea2862fdef
283 changed files with 1164 additions and 1969 deletions
|
|
@ -36,6 +36,7 @@ class PrinterController < ApplicationController
|
|||
json = JSON.parse data, symbolize_names: true
|
||||
job = PrinterJob.unfinished.find_by_id(json[:id])
|
||||
return unless job
|
||||
|
||||
if json[:state]
|
||||
job.add_update! json[:state], json[:message]
|
||||
end
|
||||
|
|
@ -54,5 +55,4 @@ class PrinterController < ApplicationController
|
|||
return head(:unauthorized) unless bearer_token
|
||||
return head(:forbidden) if bearer_token != FoodsoftConfig[:printer_token]
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ class PrinterJobsController < ApplicationController
|
|||
PrinterJob.transaction do
|
||||
%w(articles fax groups matrix).each do |document|
|
||||
next unless FoodsoftConfig["printer_print_order_#{document}"]
|
||||
|
||||
job = PrinterJob.create! order: order, document: document, created_by: current_user
|
||||
job.add_update! state
|
||||
count += 1
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class PrinterJob < ActiveRecord::Base
|
||||
|
||||
belongs_to :order
|
||||
belongs_to :created_by, class_name: 'User', foreign_key: 'created_by_user_id'
|
||||
belongs_to :finished_by, optional: true, class_name: 'User', foreign_key: 'finished_by_user_id'
|
||||
|
|
@ -7,8 +6,8 @@ class PrinterJob < ActiveRecord::Base
|
|||
|
||||
scope :finished, -> { where.not(finished_at: nil) }
|
||||
scope :unfinished, -> { where(finished_at: nil).order(:id) }
|
||||
scope :pending, -> { unfinished.includes(:order).where.not(orders: {state: 'open'}) }
|
||||
scope :queued, -> { unfinished.includes(:order).where(orders: {state: 'open'}) }
|
||||
scope :pending, -> { unfinished.includes(:order).where.not(orders: { state: 'open' }) }
|
||||
scope :queued, -> { unfinished.includes(:order).where(orders: { state: 'open' }) }
|
||||
|
||||
def last_update_at
|
||||
printer_job_updates.order(:created_at).last.try(&:created_at)
|
||||
|
|
@ -18,14 +17,15 @@ class PrinterJob < ActiveRecord::Base
|
|||
printer_job_updates.order(:created_at).last.try(&:state)
|
||||
end
|
||||
|
||||
def add_update!(state, message=nil)
|
||||
def add_update!(state, message = nil)
|
||||
return unless finished_at.nil?
|
||||
|
||||
PrinterJobUpdate.create! printer_job: self, state: state, message: message
|
||||
end
|
||||
|
||||
def finish!(user=nil)
|
||||
def finish!(user = nil)
|
||||
return unless finished_at.nil?
|
||||
|
||||
update_attributes finished_at: Time.now, finished_by: user
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
class PrinterJobUpdate < ActiveRecord::Base
|
||||
|
||||
belongs_to :printer_job
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue