Added acces rules for jobs, operator/jobs and admin/dashboard view, including lazy loading for cancel button in broadcasts

This commit is contained in:
2024-09-13 14:27:50 +02:00
parent 64289d045d
commit 418b41556e
19 changed files with 145 additions and 11 deletions

View File

@@ -1,8 +1,11 @@
class JobsController < ApplicationController
skip_before_action :authenticate_user!, only: :index
skip_before_action :authenticate_user!, only: [ :index, :cancel_button ]
skip_verify_authorized only: [ :index, :new, :create, :cancel_button ]
# GET /jobs or /jobs.json
def index
@jobs = Job.currently_working_on
@no_turbo_stream = true
end
# GET /jobs/new
@@ -28,6 +31,7 @@ class JobsController < ApplicationController
def cancel
@job = Job.find(params[:id])
authorize! @job
if @job.canceled!
flash[:notice] = "Job successfully canceled"
@status_changed = true
@@ -42,6 +46,12 @@ class JobsController < ApplicationController
end
end
def cancel_button
@job = Job.find(params[:id])
render partial: "jobs/cancel_button", locals: { job: @job }
end
private
def broadcast_update_status_cards_and_start_next_job_button