adds settings area to admin
This commit is contained in:
17
app/controllers/admin/settings_controller.rb
Normal file
17
app/controllers/admin/settings_controller.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
class Admin::SettingsController < Admin::BaseController
|
||||
|
||||
def index
|
||||
@settings = Setting.all
|
||||
end
|
||||
|
||||
def update
|
||||
@setting = Setting.find(params[:id])
|
||||
@setting.update(settings_params)
|
||||
redirect_to admin_settings_path, notice: t("admin.settings.flash.updated")
|
||||
end
|
||||
|
||||
private
|
||||
def settings_params
|
||||
params.require(:setting).permit(:value)
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,7 @@
|
||||
<ul id="admin_menu">
|
||||
<li><%= link_to t('admin.menu.settings'), admin_settings_path %></li>
|
||||
<li><%= link_to t('admin.menu.debate_topics'), admin_tags_path %></li>
|
||||
<li><%= link_to t('admin.menu.hidden_debates'), admin_debates_path %></li>
|
||||
<li><%= link_to t('admin.menu.hidden_comments'), admin_comments_path %></li>
|
||||
<li><%= link_to t('admin.officials.index.title'), admin_officials_path %></li>
|
||||
<li><%= link_to t('admin.menu.officials'), admin_officials_path %></li>
|
||||
</ul>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<% @officials.each do |official| %>
|
||||
<%= link_to official.name, edit_admin_official_path(official) %>
|
||||
<%= official.official_position %>
|
||||
<%= official.official_level %>
|
||||
<%= t("admin.officials.level_#{official.official_level}") %>
|
||||
<br/><br/>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<% @users.each do |user| %>
|
||||
<%= link_to user.name, edit_admin_official_path(user) %>
|
||||
<%= user.official_position %>
|
||||
<%= user.official_level %>
|
||||
<%= t("admin.officials.level_#{user.official_level}") %>
|
||||
<%= link_to user.official? ? t("admin.officials.search.edit_official") : t("admin.officials.search.make_official"), edit_admin_official_path(user) %>
|
||||
<% end %>
|
||||
</div>
|
||||
15
app/views/admin/settings/index.html.erb
Normal file
15
app/views/admin/settings/index.html.erb
Normal file
@@ -0,0 +1,15 @@
|
||||
<h1><%= t("admin.settings.index.title") %></h1>
|
||||
|
||||
<ul>
|
||||
<% @settings.each do |setting| %>
|
||||
<li>
|
||||
<strong><%= setting.key.classify %></strong>
|
||||
|
||||
<%= form_for(setting, url: admin_setting_path(setting), html: { id: "edit_#{dom_id(setting)}"}) do |f| %>
|
||||
<%= f.text_field :value, label: false, id: dom_id(setting) %>
|
||||
<%= f.submit(class: "button radius tiny") %>
|
||||
<% end %>
|
||||
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
Reference in New Issue
Block a user