Update legislation process translatable fields
This commit is contained in:
@@ -46,10 +46,6 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
|
|||||||
|
|
||||||
def allowed_params
|
def allowed_params
|
||||||
[
|
[
|
||||||
:title,
|
|
||||||
:summary,
|
|
||||||
:description,
|
|
||||||
:additional_info,
|
|
||||||
:start_date,
|
:start_date,
|
||||||
:end_date,
|
:end_date,
|
||||||
:debate_start_date,
|
:debate_start_date,
|
||||||
@@ -67,7 +63,7 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
|
|||||||
:result_publication_enabled,
|
:result_publication_enabled,
|
||||||
:published,
|
:published,
|
||||||
:custom_list,
|
:custom_list,
|
||||||
*translation_params(::Legislation::Process),
|
translation_params(::Legislation::Process),
|
||||||
documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
|
documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ class Legislation::Process < ActiveRecord::Base
|
|||||||
translates :description, touch: true
|
translates :description, touch: true
|
||||||
translates :additional_info, touch: true
|
translates :additional_info, touch: true
|
||||||
globalize_accessors
|
globalize_accessors
|
||||||
|
accepts_nested_attributes_for :translations, allow_destroy: true
|
||||||
|
|
||||||
PHASES_AND_PUBLICATIONS = %i(debate_phase allegations_phase proposals_phase draft_publication result_publication).freeze
|
PHASES_AND_PUBLICATIONS = %i(debate_phase allegations_phase proposals_phase draft_publication result_publication).freeze
|
||||||
|
|
||||||
@@ -24,7 +25,10 @@ class Legislation::Process < ActiveRecord::Base
|
|||||||
has_many :questions, -> { order(:id) }, class_name: 'Legislation::Question', foreign_key: 'legislation_process_id', dependent: :destroy
|
has_many :questions, -> { order(:id) }, class_name: 'Legislation::Question', foreign_key: 'legislation_process_id', dependent: :destroy
|
||||||
has_many :proposals, -> { order(:id) }, class_name: 'Legislation::Proposal', foreign_key: 'legislation_process_id', dependent: :destroy
|
has_many :proposals, -> { order(:id) }, class_name: 'Legislation::Proposal', foreign_key: 'legislation_process_id', dependent: :destroy
|
||||||
|
|
||||||
validates :title, presence: true
|
translation_class.instance_eval do
|
||||||
|
validates :title, presence: true
|
||||||
|
end
|
||||||
|
|
||||||
validates :start_date, presence: true
|
validates :start_date, presence: true
|
||||||
validates :end_date, presence: true
|
validates :end_date, presence: true
|
||||||
validates :debate_start_date, presence: true, if: :debate_end_date?
|
validates :debate_start_date, presence: true, if: :debate_end_date?
|
||||||
|
|||||||
@@ -173,37 +173,33 @@
|
|||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="small-12 medium-9 column">
|
<%= f.translatable_fields do |translations_form| %>
|
||||||
<%= f.translatable_text_field :title,
|
<div class="small-12 medium-9 column">
|
||||||
placeholder: t("admin.legislation.processes.form.title_placeholder") %>
|
<%= translations_form.text_field :title,
|
||||||
</div>
|
placeholder: t("admin.legislation.processes.form.title_placeholder") %>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="small-12 medium-9 column">
|
<div class="small-12 medium-9 column">
|
||||||
<%= f.label :summary %>
|
<%= translations_form.text_area :summary,
|
||||||
<span class="help-text"><%= t("admin.legislation.processes.form.use_markdown") %></span>
|
rows: 2,
|
||||||
<%= f.translatable_text_area :summary,
|
placeholder: t("admin.legislation.processes.form.summary_placeholder"),
|
||||||
rows: 2,
|
hint: t("admin.legislation.processes.form.use_markdown") %>
|
||||||
placeholder: t("admin.legislation.processes.form.summary_placeholder"),
|
</div>
|
||||||
label: false %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="small-12 medium-9 column">
|
<div class="small-12 medium-9 column">
|
||||||
<%= f.label :description %>
|
<%= translations_form.text_area :description,
|
||||||
<span class="help-text"><%= t("admin.legislation.processes.form.use_markdown") %></span>
|
rows: 5,
|
||||||
<%= f.translatable_text_area :description,
|
placeholder: t("admin.legislation.processes.form.description_placeholder"),
|
||||||
rows: 5,
|
hint: t("admin.legislation.processes.form.use_markdown") %>
|
||||||
placeholder: t("admin.legislation.processes.form.description_placeholder"),
|
</div>
|
||||||
label: false %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="small-12 medium-9 column">
|
<div class="small-12 medium-9 column">
|
||||||
<%= f.label :additional_info %>
|
<%= translations_form.text_area :additional_info,
|
||||||
<span class="help-text"><%= t("admin.legislation.processes.form.use_markdown") %></span>
|
rows: 10,
|
||||||
<%= f.translatable_text_area :additional_info,
|
placeholder: t("admin.legislation.processes.form.additional_info_placeholder"),
|
||||||
rows: 10,
|
hint: t("admin.legislation.processes.form.use_markdown") %>
|
||||||
placeholder: t("admin.legislation.processes.form.additional_info_placeholder"),
|
</div>
|
||||||
label: false %>
|
<% end %>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="small-12 medium-3 column clear end">
|
<div class="small-12 medium-3 column clear end">
|
||||||
<%= f.submit(class: "button success expanded", value: t("admin.legislation.processes.#{admin_submit_action(@process)}.submit_button")) %>
|
<%= f.submit(class: "button success expanded", value: t("admin.legislation.processes.#{admin_submit_action(@process)}.submit_button")) %>
|
||||||
|
|||||||
@@ -225,6 +225,11 @@ en:
|
|||||||
allegations_start_date: Allegations start date
|
allegations_start_date: Allegations start date
|
||||||
allegations_end_date: Allegations end date
|
allegations_end_date: Allegations end date
|
||||||
result_publication_date: Final result publication date
|
result_publication_date: Final result publication date
|
||||||
|
legislation/process/translation:
|
||||||
|
title: Process Title
|
||||||
|
summary: Summary
|
||||||
|
description: Description
|
||||||
|
additional_info: Additional info
|
||||||
legislation/draft_version:
|
legislation/draft_version:
|
||||||
title: Version title
|
title: Version title
|
||||||
body: Text
|
body: Text
|
||||||
|
|||||||
@@ -43,9 +43,9 @@ feature 'Admin legislation processes' do
|
|||||||
|
|
||||||
click_link "New process"
|
click_link "New process"
|
||||||
|
|
||||||
fill_in 'legislation_process_title_en', with: 'An example legislation process'
|
fill_in 'Process Title', with: 'An example legislation process'
|
||||||
fill_in 'legislation_process_summary_en', with: 'Summary of the process'
|
fill_in 'Summary', with: 'Summary of the process'
|
||||||
fill_in 'legislation_process_description_en', with: 'Describing the process'
|
fill_in 'Description', with: 'Describing the process'
|
||||||
|
|
||||||
base_date = Date.current
|
base_date = Date.current
|
||||||
fill_in 'legislation_process[start_date]', with: base_date.strftime("%d/%m/%Y")
|
fill_in 'legislation_process[start_date]', with: base_date.strftime("%d/%m/%Y")
|
||||||
@@ -98,7 +98,7 @@ feature 'Admin legislation processes' do
|
|||||||
expect(find("#legislation_process_debate_phase_enabled")).to be_checked
|
expect(find("#legislation_process_debate_phase_enabled")).to be_checked
|
||||||
expect(find("#legislation_process_published")).to be_checked
|
expect(find("#legislation_process_published")).to be_checked
|
||||||
|
|
||||||
fill_in 'legislation_process_summary_en', with: ''
|
fill_in 'Summary', with: ''
|
||||||
click_button "Save changes"
|
click_button "Save changes"
|
||||||
|
|
||||||
expect(page).to have_content "Process updated successfully"
|
expect(page).to have_content "Process updated successfully"
|
||||||
|
|||||||
Reference in New Issue
Block a user