Allow admins to moderate investments
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
class Admin::HiddenBudgetInvestmentsController < Admin::BaseController
|
||||
include FeatureFlags
|
||||
|
||||
has_filters %w{all with_confirmed_hide without_confirmed_hide}, only: :index
|
||||
|
||||
feature_flag :budgets
|
||||
|
||||
before_action :load_investment, only: [:confirm_hide, :restore]
|
||||
|
||||
def index
|
||||
@investments = Budget::Investment.only_hidden.send(@current_filter)
|
||||
.order(hidden_at: :desc)
|
||||
.page(params[:page])
|
||||
end
|
||||
|
||||
def confirm_hide
|
||||
@investment.confirm_hide
|
||||
redirect_to request.query_parameters.merge(action: :index)
|
||||
end
|
||||
|
||||
def restore
|
||||
@investment.restore
|
||||
@investment.ignore_flag
|
||||
Activity.log(current_user, :restore, @investment)
|
||||
redirect_to request.query_parameters.merge(action: :index)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_investment
|
||||
@investment = Budget::Investment.with_hidden.find(params[:id])
|
||||
end
|
||||
|
||||
end
|
||||
@@ -13,7 +13,7 @@ module AdminHelper
|
||||
end
|
||||
|
||||
def menu_moderated_content?
|
||||
["proposals", "debates", "comments", "hidden_users", "activity"].include?(controller_name) && controller.class.parent != Admin::Legislation
|
||||
["proposals", "debates", "comments", "hidden_users", "activity", "hidden_budget_investments"].include?(controller_name) && controller.class.parent != Admin::Legislation
|
||||
end
|
||||
|
||||
def menu_budget?
|
||||
|
||||
@@ -145,6 +145,12 @@
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<% if feature?(:budgets) %>
|
||||
<li <%= "class=is-active" if controller_name == "hidden_budget_investments" %>>
|
||||
<%= link_to t("admin.menu.hidden_budget_investments"), admin_hidden_budget_investments_path %>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<li <%= "class=is-active" if controller_name == "comments" %>>
|
||||
<%= link_to t("admin.menu.hidden_comments"), admin_comments_path %>
|
||||
</li>
|
||||
|
||||
49
app/views/admin/hidden_budget_investments/index.html.erb
Normal file
49
app/views/admin/hidden_budget_investments/index.html.erb
Normal file
@@ -0,0 +1,49 @@
|
||||
<h2><%= t("admin.hidden_budget_investments.index.title") %></h2>
|
||||
<p><%= t("admin.shared.moderated_content") %></p>
|
||||
|
||||
<%= render 'shared/filter_subnav', i18n_namespace: "admin.hidden_budget_investments.index" %>
|
||||
|
||||
<% if @investments.any? %>
|
||||
<h3 class="margin"><%= page_entries_info @investments %></h3>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<th scope="col"><%= t("admin.shared.title") %></th>
|
||||
<th scope="col" class="small-6"><%= t("admin.shared.description") %></th>
|
||||
<th scope="col" class="small-4"><%= t("admin.shared.actions") %></th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @investments.each do |investment| %>
|
||||
<tr id="<%= dom_id(investment) %>">
|
||||
<td class="align-top">
|
||||
<strong><%= investment.title %></strong>
|
||||
</td>
|
||||
<td>
|
||||
<div class="moderation-description">
|
||||
<%= investment.description %>
|
||||
</div>
|
||||
</td>
|
||||
<td class="align-top">
|
||||
<%= link_to t("admin.actions.restore"),
|
||||
restore_admin_hidden_budget_investment_path(investment, request.query_parameters),
|
||||
method: :put,
|
||||
data: { confirm: t("admin.actions.confirm") },
|
||||
class: "button hollow warning" %>
|
||||
<% unless investment.confirmed_hide? %>
|
||||
<%= link_to t("admin.actions.confirm_hide"),
|
||||
confirm_hide_admin_hidden_budget_investment_path(investment, request.query_parameters),
|
||||
method: :put,
|
||||
class: "button" %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%= paginate @investments %>
|
||||
<% else %>
|
||||
<div class="callout primary margin">
|
||||
<%= t("admin.hidden_budget_investments.index.no_hidden_budget_investments") %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -343,6 +343,15 @@ en:
|
||||
hidden_at: 'Hidden at:'
|
||||
registered_at: 'Registered at:'
|
||||
title: Activity of user (%{user})
|
||||
hidden_budget_investments:
|
||||
index:
|
||||
filter: Filter
|
||||
filters:
|
||||
all: All
|
||||
with_confirmed_hide: Confirmed
|
||||
without_confirmed_hide: Pending
|
||||
title: Hidden budgets investments
|
||||
no_hidden_budget_investments: There are no hidden budget investments
|
||||
legislation:
|
||||
processes:
|
||||
create:
|
||||
@@ -512,6 +521,7 @@ en:
|
||||
hidden_comments: Hidden comments
|
||||
hidden_debates: Hidden debates
|
||||
hidden_proposals: Hidden proposals
|
||||
hidden_budget_investments: Hidden budget investments
|
||||
hidden_proposal_notifications: Hidden proposal notifications
|
||||
hidden_users: Hidden users
|
||||
administrators: Administrators
|
||||
|
||||
@@ -343,6 +343,15 @@ es:
|
||||
hidden_at: 'Bloqueado:'
|
||||
registered_at: 'Fecha de alta:'
|
||||
title: Actividad del usuario (%{user})
|
||||
hidden_budget_investments:
|
||||
index:
|
||||
filter: Filtro
|
||||
filters:
|
||||
all: Todos
|
||||
with_confirmed_hide: Confirmados
|
||||
without_confirmed_hide: Pendientes
|
||||
title: Proyectos de gasto ocultos
|
||||
no_hidden_budget_investments: No hay proyectos de gasto ocultos
|
||||
legislation:
|
||||
processes:
|
||||
create:
|
||||
@@ -512,6 +521,7 @@ es:
|
||||
hidden_comments: Comentarios ocultos
|
||||
hidden_debates: Debates ocultos
|
||||
hidden_proposals: Propuestas ocultas
|
||||
hidden_budget_investments: Proyectos de gasto ocultos
|
||||
hidden_proposal_notifications: Notificationes de propuesta ocultas
|
||||
hidden_users: Usuarios bloqueados
|
||||
administrators: Administradores
|
||||
|
||||
@@ -15,6 +15,13 @@ namespace :admin do
|
||||
end
|
||||
end
|
||||
|
||||
resources :hidden_budget_investments, only: :index do
|
||||
member do
|
||||
put :restore
|
||||
put :confirm_hide
|
||||
end
|
||||
end
|
||||
|
||||
resources :debates, only: :index do
|
||||
member do
|
||||
put :restore
|
||||
|
||||
Reference in New Issue
Block a user