Skip to content
Snippets Groups Projects
Commit 3c6302cd authored by pabois's avatar pabois
Browse files

model ok

parent cdb6be2f
No related branches found
No related tags found
No related merge requests found
......@@ -27,12 +27,7 @@ class Admin::Communication::Website::IndexPagesController < Admin::Communication
protected
def get_index_page
kind = params[:kind]
@index_page = @website.index_pages.where(kind: kind).first_or_initialize(
title: t("communication.website.index_pages.default.#{kind}.title"),
path: t("communication.website.index_pages.default.#{kind}.path"),
description: t("communication.website.index_pages.default.#{kind}.description")
)
@index_page = @website.index_for(params[:kind])
end
def ensure_abilities
......@@ -48,8 +43,9 @@ class Admin::Communication::Website::IndexPagesController < Admin::Communication
def index_page_params
params.require(:communication_website_index_page)
.permit(
:title, :description, :text, :featured_image, :featured_image_delete,
:title, :description, :text, :path, :featured_image, :featured_image_delete,
:featured_image_infos, :featured_image_alt
)
.merge(university_id: current_university.id)
end
end
......@@ -40,9 +40,4 @@ class Communication::Website::IndexPage < ApplicationRecord
validates :title, :path, presence: true
def to_s
Communication::Website::IndexPage.human_attribute_name("kind_#{kind}")
end
end
......@@ -6,6 +6,14 @@ module Communication::Website::WithIndexPages
class_name: 'Communication::Website::IndexPage',
foreign_key: :communication_website_id,
dependent: :destroy
def index_for(kind)
index_pages.where(kind: kind).first_or_initialize(
title: I18n.t("communication.website.index_pages.default.#{kind}.title"),
path: I18n.t("communication.website.index_pages.default.#{kind}.path"),
description: I18n.t("communication.website.index_pages.default.#{kind}.description")
)
end
end
end
......@@ -17,7 +17,7 @@
data: { source: '#communication_website_index_page_title' }
} %>
<%= f.input :description %>
<%= f.input :text, as: :rich_text_area %>
<%= f.input :text %>
</div>
</div>
</div>
......
......@@ -41,6 +41,8 @@ namespace :communication do
get 'indexes' => 'website/index_pages#index'
get 'indexes/:kind' => 'website/index_pages#edit', as: :index
post 'indexes/:kind' => 'website/index_pages#update'
patch 'indexes/:kind' => 'website/index_pages#update'
put 'indexes/:kind' => 'website/index_pages#update'
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment