diff --git a/app/models/job.rb b/app/models/job.rb index 8229bf2..57763ab 100644 --- a/app/models/job.rb +++ b/app/models/job.rb @@ -1,6 +1,7 @@ -include ActionView::Helpers::UrlHelper - class Job < ActiveRecord::Base + include ActionView::Helpers::UrlHelper + include Redmine::SafeAttributes + validates :starts_on, :ends_on, :name, @@ -16,6 +17,8 @@ class Job < ActiveRecord::Base scope :project_or_parent, ->(project) { where(project_id: [project&.id, project&.parent&.id]) } scope :active, -> { where(starts_on: ..Date.today, ends_on: Date.today..) } + safe_attributes 'name', 'description' + def with_all_time_budgets time_budgets.build(job_id: id, category_id: nil) unless time_budgets.where(category_id: nil).exists? TimeBudgetCategory.where.not(id: time_budgets.pluck(:category_id)).each do |category| diff --git a/app/views/jobs/_form.html.erb b/app/views/jobs/_form.html.erb index c5e219f..4feec0f 100644 --- a/app/views/jobs/_form.html.erb +++ b/app/views/jobs/_form.html.erb @@ -2,12 +2,8 @@ <%= error_messages_for @job %>

- <%= f.label :name %> - <%= f.text_field :name %> - -

- <%= f.label :description %> - <%= f.text_area :description %> + + <%= f.text_field :name, required: true %>

<%= f.label :category %> @@ -21,6 +17,11 @@ <%= f.label :ends_on %> <%= f.date_field :ends_on %> +

+ <%= f.label :description %> + <%= f.text_area :description, required: true, cols: 60, rows: 15, class: "wiki-edit", + data: { auto_complete: true }, id: "job_description" %> + <%= f.hidden_field :project_id, value: @job.project.id %>

@@ -34,6 +35,7 @@ <%= ff.hidden_field :_destroy, value: false %> <% end %>
+<%= wikitoolbar_for 'job_description' %>
<%= f.submit %> diff --git a/app/views/jobs/show.html.erb b/app/views/jobs/show.html.erb index 27b8f47..940e38b 100644 --- a/app/views/jobs/show.html.erb +++ b/app/views/jobs/show.html.erb @@ -15,7 +15,7 @@

Job #<%= @job.id %>

<%= @job.name %>

-

<%= @job.description %>

+

<%= textilizable(@job, :description) %>