diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index 7fc246c39..0b6553688 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -99,7 +99,7 @@ def set_category def category_params if params[:category] params.require(:category).permit( - :name, :category_type_id, :published, :position + :name, :name_spanish, :category_type_id, :published, :position ) else params.permit(:position) diff --git a/app/controllers/category_types_controller.rb b/app/controllers/category_types_controller.rb index cc4a3ea52..5235ab8b1 100644 --- a/app/controllers/category_types_controller.rb +++ b/app/controllers/category_types_controller.rb @@ -59,6 +59,6 @@ def set_category_type end def category_type_params - params.require(:category_type).permit(:name, :display_text, :published, :story_specific, :profile_specific) + params.require(:category_type).permit(:name, :name_spanish, :display_text, :published, :story_specific, :profile_specific) end end diff --git a/app/controllers/sectors_controller.rb b/app/controllers/sectors_controller.rb index ece19f646..e898e8953 100644 --- a/app/controllers/sectors_controller.rb +++ b/app/controllers/sectors_controller.rb @@ -75,7 +75,7 @@ def set_sector # Strong parameters def sector_params params.require(:sector).permit( - :name, :published + :name, :name_spanish, :published ) end end diff --git a/app/controllers/workshops_controller.rb b/app/controllers/workshops_controller.rb index 03ac9f226..2715d69b2 100644 --- a/app/controllers/workshops_controller.rb +++ b/app/controllers/workshops_controller.rb @@ -219,7 +219,7 @@ def log_workshop_error(action, error) def workshop_params params.require(:workshop).permit( - :title, :featured, :published, + :title, :title_spanish, :featured, :published, :full_name, :created_by_id, :windows_type_id, :workshop_idea_id, :author_credit_preference, :month, :year, :publicly_visible, diff --git a/app/decorators/category_decorator.rb b/app/decorators/category_decorator.rb index 3ddc956af..6d54e0324 100644 --- a/app/decorators/category_decorator.rb +++ b/app/decorators/category_decorator.rb @@ -3,7 +3,16 @@ def title name end + def title_spanish + name_spanish.presence || name + end + def detail(length: nil) "#{category_type.name}: #{name}" end + + def detail_spanish(length: nil) + type_label = category_type.name_spanish.presence || category_type.name + "#{type_label}: #{name_spanish.presence || name}" + end end diff --git a/app/decorators/category_type_decorator.rb b/app/decorators/category_type_decorator.rb index e49c32ec3..8c61fd79f 100644 --- a/app/decorators/category_type_decorator.rb +++ b/app/decorators/category_type_decorator.rb @@ -3,6 +3,10 @@ def title name.titleize end + def title_spanish + name_spanish.presence&.titleize || name.titleize + end + def detail(length: nil) end end diff --git a/app/decorators/workshop_decorator.rb b/app/decorators/workshop_decorator.rb index fb3a5ac10..59e7745ce 100644 --- a/app/decorators/workshop_decorator.rb +++ b/app/decorators/workshop_decorator.rb @@ -19,7 +19,7 @@ def field_has_empty_value?(field) end def has_spanish_fields? - spanish_field_values.any? + title_spanish.present? || spanish_field_values.any? end def new? diff --git a/app/views/categories/_form.html.erb b/app/views/categories/_form.html.erb index 3b5f27453..13e5193ba 100644 --- a/app/views/categories/_form.html.erb +++ b/app/views/categories/_form.html.erb @@ -15,6 +15,13 @@ input_html: { class: "form-control" } %> + +
Name:
<%= @category.name %>
Name (Spanish):
+<%= @category.name_spanish.presence || "--" %>
+Category type:
<%= @category.category_type.name %>
diff --git a/app/views/category_types/_form.html.erb b/app/views/category_types/_form.html.erb index b7a17fee8..ba8d70fd7 100644 --- a/app/views/category_types/_form.html.erb +++ b/app/views/category_types/_form.html.erb @@ -8,6 +8,9 @@ label: "Name", input_html: { class: "form-control" }, required: true %> + <%= f.input :name_spanish, + label: "Name (Spanish)", + input_html: { class: "form-control" } %> <%= f.input :display_text, label: "Display Text", hint: "For display on story idea form", diff --git a/app/views/category_types/show.html.erb b/app/views/category_types/show.html.erb index a228efaa1..06d377f64 100644 --- a/app/views/category_types/show.html.erb +++ b/app/views/category_types/show.html.erb @@ -41,6 +41,10 @@ Display text: <%= @category_type.display_text %> ++ Name (Spanish): + <%= @category_type.name_spanish.presence || "--" %> +
Name:
<%= @sector.name %>
Name (Spanish):
+<%= @sector.name_spanish.presence || "--" %>
+Published:
<%= @sector.published? %>
diff --git a/app/views/workshops/_form.html.erb b/app/views/workshops/_form.html.erb index e84f6f791..dbe180c2d 100644 --- a/app/views/workshops/_form.html.erb +++ b/app/views/workshops/_form.html.erb @@ -369,6 +369,11 @@