Allow admins to moderate investments

This commit is contained in:
Angel Perez
2018-06-18 10:12:09 -04:00
parent 1990092fdf
commit 4da23716bb
7 changed files with 117 additions and 1 deletions

View File

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

View File

@@ -13,7 +13,7 @@ module AdminHelper
end end
def menu_moderated_content? 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 end
def menu_budget? def menu_budget?

View File

@@ -145,6 +145,12 @@
</li> </li>
<% end %> <% 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" %>> <li <%= "class=is-active" if controller_name == "comments" %>>
<%= link_to t("admin.menu.hidden_comments"), admin_comments_path %> <%= link_to t("admin.menu.hidden_comments"), admin_comments_path %>
</li> </li>

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

View File

@@ -343,6 +343,15 @@ en:
hidden_at: 'Hidden at:' hidden_at: 'Hidden at:'
registered_at: 'Registered at:' registered_at: 'Registered at:'
title: Activity of user (%{user}) 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: legislation:
processes: processes:
create: create:
@@ -512,6 +521,7 @@ en:
hidden_comments: Hidden comments hidden_comments: Hidden comments
hidden_debates: Hidden debates hidden_debates: Hidden debates
hidden_proposals: Hidden proposals hidden_proposals: Hidden proposals
hidden_budget_investments: Hidden budget investments
hidden_proposal_notifications: Hidden proposal notifications hidden_proposal_notifications: Hidden proposal notifications
hidden_users: Hidden users hidden_users: Hidden users
administrators: Administrators administrators: Administrators

View File

@@ -343,6 +343,15 @@ es:
hidden_at: 'Bloqueado:' hidden_at: 'Bloqueado:'
registered_at: 'Fecha de alta:' registered_at: 'Fecha de alta:'
title: Actividad del usuario (%{user}) 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: legislation:
processes: processes:
create: create:
@@ -512,6 +521,7 @@ es:
hidden_comments: Comentarios ocultos hidden_comments: Comentarios ocultos
hidden_debates: Debates ocultos hidden_debates: Debates ocultos
hidden_proposals: Propuestas ocultas hidden_proposals: Propuestas ocultas
hidden_budget_investments: Proyectos de gasto ocultos
hidden_proposal_notifications: Notificationes de propuesta ocultas hidden_proposal_notifications: Notificationes de propuesta ocultas
hidden_users: Usuarios bloqueados hidden_users: Usuarios bloqueados
administrators: Administradores administrators: Administradores

View File

@@ -15,6 +15,13 @@ namespace :admin do
end end
end end
resources :hidden_budget_investments, only: :index do
member do
put :restore
put :confirm_hide
end
end
resources :debates, only: :index do resources :debates, only: :index do
member do member do
put :restore put :restore