From 1c032cc42e84810e8c4f08b2a74bdd4e1ec0bbf3 Mon Sep 17 00:00:00 2001 From: Trevor Vallender Date: Sun, 26 Nov 2023 20:25:27 +0000 Subject: [PATCH] Fix permissions and form variables --- app/controllers/jobs_controller.rb | 2 +- app/views/jobs/_form.html.erb | 2 +- app/views/jobs/edit.html.erb | 2 +- app/views/jobs/new.html.erb | 2 +- init.rb | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/jobs_controller.rb b/app/controllers/jobs_controller.rb index ba00706..0f06949 100644 --- a/app/controllers/jobs_controller.rb +++ b/app/controllers/jobs_controller.rb @@ -10,7 +10,7 @@ class JobsController < ApplicationController end def new - @job = Job.new.with_all_time_budgets + @job = Job.new(project_id: @project.id).with_all_time_budgets end def edit diff --git a/app/views/jobs/_form.html.erb b/app/views/jobs/_form.html.erb index 026d0f7..8c5fd97 100644 --- a/app/views/jobs/_form.html.erb +++ b/app/views/jobs/_form.html.erb @@ -1,4 +1,4 @@ -<%= form_with model: @job, url: job_path(@job, project_id: @job.project.id), id: "job_form" do |f| %> +<%= form_with model: @job, url: form_target, id: "job_form" do |f| %> <%= error_messages_for @job %>

diff --git a/app/views/jobs/edit.html.erb b/app/views/jobs/edit.html.erb index a07e61d..fe4d4aa 100644 --- a/app/views/jobs/edit.html.erb +++ b/app/views/jobs/edit.html.erb @@ -1,5 +1,5 @@ <% html_title "Edit #{@job.name}" %>

Edit <%= @job.name %>

-<%= render "form" %> +<%= render partial: "form", locals: { form_target: job_path(@job, project_id: @job.project) } %> diff --git a/app/views/jobs/new.html.erb b/app/views/jobs/new.html.erb index bc1edae..e8c3843 100644 --- a/app/views/jobs/new.html.erb +++ b/app/views/jobs/new.html.erb @@ -1,3 +1,3 @@

<%= link_to "Jobs", jobs_path(project_id: @project.id) %> ยป New

-<%= render "form" %> +<%= render partial: "form", locals: { form_target: jobs_path } %> diff --git a/init.rb b/init.rb index 11023f4..31748a5 100644 --- a/init.rb +++ b/init.rb @@ -6,7 +6,7 @@ Redmine::Plugin.register :jobs do url 'http://tsvallender.co.uk' author_url 'http://tsvallender.co.uk' - permission :jobs, { jobs: [:index, :show, :new, :create, :edit, :update, :destroy] }, public: true + permission :jobs, { jobs: [:index, :show, :new, :create, :edit, :update, :destroy] }, public: false menu :project_menu, :jobs, { controller: 'jobs', action: 'index' }, caption: 'Jobs', after: :issues, param: :project_id TimeEntry.safe_attributes 'job_id'