adds activity page to administration
This commit is contained in:
8
app/controllers/admin/activity_controller.rb
Normal file
8
app/controllers/admin/activity_controller.rb
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
class Admin::ActivityController < Admin::BaseController
|
||||||
|
has_filters %w{all on_users on_proposals on_debates on_comments}
|
||||||
|
|
||||||
|
def show
|
||||||
|
@activity = Activity.for_render.send(@current_filter).order(created_at: :desc).page(params[:page])
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -16,6 +16,7 @@ class Moderation::ProposalsController < Moderation::BaseController
|
|||||||
|
|
||||||
def hide
|
def hide
|
||||||
@proposal.hide
|
@proposal.hide
|
||||||
|
Activity.log(current_user, :hide, @proposal)
|
||||||
end
|
end
|
||||||
|
|
||||||
def moderate
|
def moderate
|
||||||
|
|||||||
@@ -60,6 +60,13 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
<li <%= 'class=active' if controller_name == 'activity' %>>
|
||||||
|
<%= link_to admin_activity_path do %>
|
||||||
|
<i class="icon-eye"></i>
|
||||||
|
<%= t('admin.menu.activity') %>
|
||||||
|
<% end %>
|
||||||
|
</li>
|
||||||
|
|
||||||
<li <%= 'class=active' if controller_name == 'settings' %>>
|
<li <%= 'class=active' if controller_name == 'settings' %>>
|
||||||
<%= link_to admin_settings_path do %>
|
<%= link_to admin_settings_path do %>
|
||||||
<i class="icon-settings"></i>
|
<i class="icon-settings"></i>
|
||||||
|
|||||||
43
app/views/admin/activity/show.html.erb
Normal file
43
app/views/admin/activity/show.html.erb
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<h2><%= t("admin.activity.show.title") %></h2>
|
||||||
|
|
||||||
|
<%= render 'shared/filter_subnav', i18n_namespace: "admin.activity.show" %>
|
||||||
|
|
||||||
|
<h3><%= page_entries_info @activity %></h3>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th><%= t("admin.activity.show.type") %></th>
|
||||||
|
<th><%= t("admin.activity.show.action") %></th>
|
||||||
|
<th> </th>
|
||||||
|
<th><%= t("admin.activity.show.by") %></th>
|
||||||
|
</tr>
|
||||||
|
<% @activity.each do |activity| %>
|
||||||
|
<tr id="<%= dom_id(activity) %>">
|
||||||
|
<td>
|
||||||
|
<%= activity.actionable_type.constantize.model_name.human %><br>
|
||||||
|
<span class="date"><%= l activity.actionable.created_at.to_date %></span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= t("admin.activity.show.actions.#{activity.action}") %><br>
|
||||||
|
<span class="date"><%= l activity.created_at.to_date %></span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<% case activity.actionable_type %>
|
||||||
|
<% when "User" %>
|
||||||
|
<%= activity.actionable.username %> (<%= activity.actionable.email %>)
|
||||||
|
<% when "Comment" %>
|
||||||
|
<%= activity.actionable.body %>
|
||||||
|
<% else %>
|
||||||
|
<strong><%= activity.actionable.title %></strong>
|
||||||
|
<br>
|
||||||
|
<div class="proposal-description">
|
||||||
|
<%= activity.actionable.description %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td><%= activity.user.name %> (<%= activity.user.email %>)</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<%= paginate @activity %>
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
en:
|
en:
|
||||||
activerecord:
|
activerecord:
|
||||||
models:
|
models:
|
||||||
|
activity: Activity
|
||||||
comment: Comment
|
comment: Comment
|
||||||
debate: Debate
|
debate: Debate
|
||||||
proposal: Proposal
|
proposal: Proposal
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
es:
|
es:
|
||||||
activerecord:
|
activerecord:
|
||||||
models:
|
models:
|
||||||
|
activity:
|
||||||
|
one: actividad
|
||||||
|
other: actividades
|
||||||
comment:
|
comment:
|
||||||
one: Comentario
|
one: Comentario
|
||||||
other: Comentarios
|
other: Comentarios
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ en:
|
|||||||
officials: Officials
|
officials: Officials
|
||||||
moderators: Moderators
|
moderators: Moderators
|
||||||
stats: Statistics
|
stats: Statistics
|
||||||
|
activity: Moderation Activity
|
||||||
organizations:
|
organizations:
|
||||||
index:
|
index:
|
||||||
title: Organizations
|
title: Organizations
|
||||||
@@ -129,4 +130,18 @@ en:
|
|||||||
moderator:
|
moderator:
|
||||||
delete: Delete
|
delete: Delete
|
||||||
add: Add
|
add: Add
|
||||||
|
activity:
|
||||||
|
show:
|
||||||
|
title: Activity of Moderators
|
||||||
|
filter: Show
|
||||||
|
filters:
|
||||||
|
all: All
|
||||||
|
on_proposals: On Proposals
|
||||||
|
on_debates: On Debates
|
||||||
|
on_comments: On Comments
|
||||||
|
on_users: On Users
|
||||||
|
actions:
|
||||||
|
hide: Hidden
|
||||||
|
restore: Restored
|
||||||
|
block: Blocked
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ es:
|
|||||||
officials: Cargos públicos
|
officials: Cargos públicos
|
||||||
moderators: Moderadores
|
moderators: Moderadores
|
||||||
stats: Estadísticas
|
stats: Estadísticas
|
||||||
|
activity: Actividad de moderadores
|
||||||
organizations:
|
organizations:
|
||||||
index:
|
index:
|
||||||
title: Organizaciones
|
title: Organizaciones
|
||||||
@@ -129,3 +130,17 @@ es:
|
|||||||
moderator:
|
moderator:
|
||||||
delete: Borrar
|
delete: Borrar
|
||||||
add: Añadir
|
add: Añadir
|
||||||
|
activity:
|
||||||
|
show:
|
||||||
|
title: Actividad de los Moderadores
|
||||||
|
filter: Mostrar
|
||||||
|
filters:
|
||||||
|
all: Todo
|
||||||
|
on_proposals: Propuestas
|
||||||
|
on_debates: Debates
|
||||||
|
on_comments: Comentarios
|
||||||
|
on_users: Usuarios
|
||||||
|
actions:
|
||||||
|
hide: Ocultado
|
||||||
|
restore: Restaurado
|
||||||
|
block: Bloqueado
|
||||||
|
|||||||
@@ -112,6 +112,8 @@ Rails.application.routes.draw do
|
|||||||
resources :moderators, only: [:index, :create, :destroy] do
|
resources :moderators, only: [:index, :create, :destroy] do
|
||||||
collection { get :search }
|
collection { get :search }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
resource :activity, controller: :activity, only: :show
|
||||||
end
|
end
|
||||||
|
|
||||||
namespace :moderation do
|
namespace :moderation do
|
||||||
|
|||||||
29
spec/features/admin/activity_spec.rb
Normal file
29
spec/features/admin/activity_spec.rb
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
feature 'Admin activity' do
|
||||||
|
|
||||||
|
background do
|
||||||
|
@admin = create(:administrator)
|
||||||
|
login_as(@admin.user)
|
||||||
|
end
|
||||||
|
|
||||||
|
context "Proposals" do
|
||||||
|
scenario "Shows moderation activity on proposals", :js do
|
||||||
|
proposal = create(:proposal)
|
||||||
|
|
||||||
|
visit proposal_path(proposal)
|
||||||
|
|
||||||
|
within("#proposal_#{proposal.id}") do
|
||||||
|
click_link 'Hide'
|
||||||
|
end
|
||||||
|
|
||||||
|
visit admin_activity_path
|
||||||
|
|
||||||
|
within("#activity_#{Activity.last.id}") do
|
||||||
|
expect(page).to have_content(proposal.title)
|
||||||
|
expect(page).to have_content(@admin.user.username)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user