Make Legistlation Processes translatable
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
class Admin::Legislation::ProcessesController < Admin::Legislation::BaseController
|
||||
include Translatable
|
||||
|
||||
has_filters %w{open next past all}, only: :index
|
||||
|
||||
load_and_authorize_resource :process, class: "Legislation::Process"
|
||||
@@ -61,6 +63,7 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
|
||||
:result_publication_enabled,
|
||||
:published,
|
||||
:custom_list,
|
||||
*translation_params(Legislation::Process),
|
||||
documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
|
||||
)
|
||||
end
|
||||
@@ -69,4 +72,8 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
|
||||
@process.set_tag_list_on(:customs, process_params[:custom_list])
|
||||
@process.save
|
||||
end
|
||||
|
||||
def resource
|
||||
@process || Legislation::Process.find(params[:id])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,6 +9,12 @@ class Legislation::Process < ActiveRecord::Base
|
||||
acts_as_paranoid column: :hidden_at
|
||||
acts_as_taggable_on :customs
|
||||
|
||||
translates :title, touch: :true
|
||||
translates :summary, touch: :true
|
||||
translates :description, touch: :true
|
||||
translates :additional_info, touch: :true
|
||||
globalize_accessors
|
||||
|
||||
PHASES_AND_PUBLICATIONS = %i(debate_phase allegations_phase proposals_phase draft_publication result_publication).freeze
|
||||
|
||||
has_many :draft_versions, -> { order(:id) }, class_name: 'Legislation::DraftVersion',
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<%= form_for [:admin, @process], html: {data: {watch_changes: true}} do |f| %>
|
||||
<%= render "admin/shared/globalize_locales", resource: @process %>
|
||||
|
||||
<%= translatable_form_for [:admin, @process], html: {data: {watch_changes: true}} do |f| %>
|
||||
|
||||
<% if @process.errors.any? %>
|
||||
|
||||
@@ -172,37 +174,35 @@
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-9 column">
|
||||
<%= f.label :title %>
|
||||
<%= f.text_field :title,
|
||||
label: false,
|
||||
placeholder: t("admin.legislation.processes.form.title_placeholder") %>
|
||||
<%= f.translatable_text_field :title,
|
||||
placeholder: t("admin.legislation.processes.form.title_placeholder") %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-9 column">
|
||||
<%= f.label :summary %>
|
||||
<span class="help-text"><%= t("admin.legislation.processes.form.use_markdown") %></span>
|
||||
<%= f.text_area :summary,
|
||||
label: false,
|
||||
rows: 2,
|
||||
placeholder: t("admin.legislation.processes.form.summary_placeholder") %>
|
||||
<%= f.translatable_text_field :summary,
|
||||
rows: 2,
|
||||
placeholder: t("admin.legislation.processes.form.summary_placeholder"),
|
||||
label: false %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-9 column">
|
||||
<%= f.label :description %>
|
||||
<span class="help-text"><%= t("admin.legislation.processes.form.use_markdown") %></span>
|
||||
<%= f.text_area :description,
|
||||
label: false,
|
||||
rows: 5,
|
||||
placeholder: t("admin.legislation.processes.form.description_placeholder") %>
|
||||
<%= f.translatable_text_field :description,
|
||||
rows: 5,
|
||||
placeholder: t("admin.legislation.processes.form.description_placeholder"),
|
||||
label: false %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-9 column">
|
||||
<%= f.label :additional_info %>
|
||||
<span class="help-text"><%= t("admin.legislation.processes.form.use_markdown") %></span>
|
||||
<%= f.text_area :additional_info,
|
||||
label: false,
|
||||
rows: 10,
|
||||
placeholder: t("admin.legislation.processes.form.additional_info_placeholder") %>
|
||||
<%= f.translatable_text_area :additional_info,
|
||||
rows: 10,
|
||||
placeholder: t("admin.legislation.processes.form.additional_info_placeholder"),
|
||||
label: false %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-3 column clear end">
|
||||
|
||||
@@ -7,6 +7,11 @@ feature 'Admin legislation processes' do
|
||||
login_as(admin.user)
|
||||
end
|
||||
|
||||
it_behaves_like "translatable",
|
||||
"legislation_process",
|
||||
"edit_admin_legislation_process_path",
|
||||
%w[title summary description additional_info]
|
||||
|
||||
context "Feature flag" do
|
||||
|
||||
scenario 'Disabled with a feature flag' do
|
||||
@@ -38,9 +43,9 @@ feature 'Admin legislation processes' do
|
||||
|
||||
click_link "New process"
|
||||
|
||||
fill_in 'legislation_process_title', with: 'An example legislation process'
|
||||
fill_in 'legislation_process_summary', with: 'Summary of the process'
|
||||
fill_in 'legislation_process_description', with: 'Describing the process'
|
||||
fill_in 'legislation_process_title_en', with: 'An example legislation process'
|
||||
fill_in 'legislation_process_summary_en', with: 'Summary of the process'
|
||||
fill_in 'legislation_process_description_en', with: 'Describing the process'
|
||||
|
||||
base_date = Date.current
|
||||
fill_in 'legislation_process[start_date]', with: base_date.strftime("%d/%m/%Y")
|
||||
@@ -93,7 +98,7 @@ feature 'Admin legislation processes' do
|
||||
expect(find("#legislation_process_debate_phase_enabled")).to be_checked
|
||||
expect(find("#legislation_process_published")).to be_checked
|
||||
|
||||
fill_in 'legislation_process_summary', with: ''
|
||||
fill_in 'legislation_process_summary_en', with: ''
|
||||
click_button "Save changes"
|
||||
|
||||
expect(page).to have_content "Process updated successfully"
|
||||
|
||||
Reference in New Issue
Block a user