Add homepage admin section

This commit is contained in:
rgarcia
2018-05-22 19:52:35 +02:00
committed by decabeza
parent 06772a7b87
commit 85c08da7a6
10 changed files with 57 additions and 4 deletions

View 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

View File

@@ -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

View File

@@ -0,0 +1,10 @@
class Admin::Widget::BaseController < Admin::BaseController
helper_method :namespace
private
def namespace
"admin"
end
end

View File

@@ -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>

View 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>

View 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 %>

View File

@@ -0,0 +1 @@
<%= render "admin/menu" %>

View File

@@ -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

View File

@@ -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

View File

@@ -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