Add homepage admin section
This commit is contained in:
12
app/controllers/admin/homepage_controller.rb
Normal file
12
app/controllers/admin/homepage_controller.rb
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
class Admin::HomepageController < Admin::BaseController
|
||||||
|
|
||||||
|
def show
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def load_settings
|
||||||
|
settings = /feature.homepage.widgets/
|
||||||
|
@settings = Setting.select {|setting| setting.key =~ /#{settings}/ }
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -11,7 +11,7 @@ class Admin::SettingsController < Admin::BaseController
|
|||||||
def update
|
def update
|
||||||
@setting = Setting.find(params[:id])
|
@setting = Setting.find(params[:id])
|
||||||
@setting.update(settings_params)
|
@setting.update(settings_params)
|
||||||
redirect_to admin_settings_path, notice: t("admin.settings.flash.updated")
|
redirect_to request.referer, notice: t("admin.settings.flash.updated")
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_map
|
def update_map
|
||||||
|
|||||||
10
app/controllers/admin/widget/base_controller.rb
Normal file
10
app/controllers/admin/widget/base_controller.rb
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
class Admin::Widget::BaseController < Admin::BaseController
|
||||||
|
helper_method :namespace
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def namespace
|
||||||
|
"admin"
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -167,6 +167,10 @@
|
|||||||
</a>
|
</a>
|
||||||
<ul <%= "class=is-active" if menu_customization? &&
|
<ul <%= "class=is-active" if menu_customization? &&
|
||||||
controller.class.parent != Admin::Poll::Questions::Answers %>>
|
controller.class.parent != Admin::Poll::Questions::Answers %>>
|
||||||
|
<li <%= "class=active" if controller_name == "homepage" %>>
|
||||||
|
<%= link_to "Homepage", admin_homepage_path %>
|
||||||
|
</li>
|
||||||
|
|
||||||
<li <%= "class=active" if controller_name == "pages" %>>
|
<li <%= "class=active" if controller_name == "pages" %>>
|
||||||
<%= link_to t("admin.menu.site_customization.pages"), admin_site_customization_pages_path %>
|
<%= link_to t("admin.menu.site_customization.pages"), admin_site_customization_pages_path %>
|
||||||
</li>
|
</li>
|
||||||
@@ -179,6 +183,7 @@
|
|||||||
<li <%= "class=active" if controller_name == "content_blocks" %>>
|
<li <%= "class=active" if controller_name == "content_blocks" %>>
|
||||||
<%= link_to t("admin.menu.site_customization.content_blocks"), admin_site_customization_content_blocks_path%>
|
<%= link_to t("admin.menu.site_customization.content_blocks"), admin_site_customization_content_blocks_path%>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|||||||
11
app/views/admin/homepage/_setting.html.erb
Normal file
11
app/views/admin/homepage/_setting.html.erb
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<div id="<%= dom_id(setting) %>">
|
||||||
|
<%= form_for(setting, url: admin_setting_path(setting), method: :put) do |f| %>
|
||||||
|
|
||||||
|
<%= f.hidden_field :value,
|
||||||
|
value: (setting.enabled? ? "" : "active") %>
|
||||||
|
|
||||||
|
<%= f.submit(t("admin.settings.index.features.#{setting.enabled? ? 'disable' : 'enable'}"),
|
||||||
|
class: "button expanded #{setting.enabled? ? 'hollow alert' : 'success'}",
|
||||||
|
data: {confirm: t("admin.actions.confirm")}) %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
11
app/views/admin/homepage/show.html.erb
Normal file
11
app/views/admin/homepage/show.html.erb
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<h1>Homepage</h1>
|
||||||
|
|
||||||
|
<p>The active modules appear in the homepage in the same order as here.</p>
|
||||||
|
<% @settings.each do |setting| %>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<strong><%= t("settings.#{setting.key}") %></strong>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= render "setting", setting: setting %>
|
||||||
|
<% end %>
|
||||||
1
app/views/admin/widget/_menu.html.erb
Normal file
1
app/views/admin/widget/_menu.html.erb
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<%= render "admin/menu" %>
|
||||||
@@ -41,7 +41,7 @@ en:
|
|||||||
voting_allowed: Voting on investment projects
|
voting_allowed: Voting on investment projects
|
||||||
legislation: Legislation
|
legislation: Legislation
|
||||||
user:
|
user:
|
||||||
recommendations: Recommendeds
|
recommendations: Recommendations
|
||||||
skip_verification: Skip user verification
|
skip_verification: Skip user verification
|
||||||
community: Community on proposals and investments
|
community: Community on proposals and investments
|
||||||
map: Proposals and budget investments geolocation
|
map: Proposals and budget investments geolocation
|
||||||
|
|||||||
@@ -179,4 +179,7 @@ namespace :admin do
|
|||||||
resources :images, only: [:index, :update, :destroy]
|
resources :images, only: [:index, :update, :destroy]
|
||||||
resources :content_blocks, except: [:show]
|
resources :content_blocks, except: [:show]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
resource :homepage, controller: :homepage
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ require 'rails_helper'
|
|||||||
|
|
||||||
feature "Home" do
|
feature "Home" do
|
||||||
|
|
||||||
feature "For not logged users" do
|
context "For not logged users" do
|
||||||
|
|
||||||
scenario 'Welcome message' do
|
scenario 'Welcome message' do
|
||||||
visit root_path
|
visit root_path
|
||||||
@@ -20,7 +20,7 @@ feature "Home" do
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
feature "For signed in users" do
|
context "For signed in users" do
|
||||||
|
|
||||||
feature "Recommended" do
|
feature "Recommended" do
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user