adds admin budgets index
This commit is contained in:
9
app/controllers/admin/budgets_controller.rb
Normal file
9
app/controllers/admin/budgets_controller.rb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
class Admin::BudgetsController < Admin::BaseController
|
||||||
|
|
||||||
|
has_filters %w{open finished}, only: :index
|
||||||
|
|
||||||
|
def index
|
||||||
|
@budgets = Budget.send(@current_filter).order(created_at: :desc).page(params[:page])
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
25
app/views/admin/budgets/index.html.erb
Normal file
25
app/views/admin/budgets/index.html.erb
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<h2 class="inline-block"><%= t("admin.budgets.index.title") %></h2>
|
||||||
|
|
||||||
|
<%= link_to t("admin.budgets.index.new_link"),
|
||||||
|
new_admin_budget_path,
|
||||||
|
class: "button float-right margin-right" %>
|
||||||
|
|
||||||
|
<%= render 'shared/filter_subnav', i18n_namespace: "admin.budgets.index" %>
|
||||||
|
|
||||||
|
|
||||||
|
<h3><%= page_entries_info @budgets %></h3>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<% @budgets.each do |budget| %>
|
||||||
|
<tr id="<%= dom_id(budget) %>" class="budget">
|
||||||
|
<td>
|
||||||
|
<%= link_to budget.name, admin_budget_path(budget) %>
|
||||||
|
</td>
|
||||||
|
<td class="small">
|
||||||
|
<%= t("budget.phase.#{budget.phase}") %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<%= paginate @budgets %>
|
||||||
@@ -4,6 +4,9 @@ en:
|
|||||||
activity:
|
activity:
|
||||||
one: "activity"
|
one: "activity"
|
||||||
other: "activities"
|
other: "activities"
|
||||||
|
budget:
|
||||||
|
one: "Participatory budget"
|
||||||
|
other: "Participatory budgets"
|
||||||
comment:
|
comment:
|
||||||
one: "Comment"
|
one: "Comment"
|
||||||
other: "Comments"
|
other: "Comments"
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ es:
|
|||||||
activity:
|
activity:
|
||||||
one: "actividad"
|
one: "actividad"
|
||||||
other: "actividades"
|
other: "actividades"
|
||||||
|
budget:
|
||||||
|
one: "Presupuesto participativo"
|
||||||
|
other: "Presupuestos participativos"
|
||||||
comment:
|
comment:
|
||||||
one: "Comentario"
|
one: "Comentario"
|
||||||
other: "Comentarios"
|
other: "Comentarios"
|
||||||
|
|||||||
@@ -60,6 +60,13 @@ en:
|
|||||||
on_users: Users
|
on_users: Users
|
||||||
title: Moderator activity
|
title: Moderator activity
|
||||||
type: Type
|
type: Type
|
||||||
|
budgets:
|
||||||
|
index:
|
||||||
|
title: Participatory budgets
|
||||||
|
new_link: Create new
|
||||||
|
filters:
|
||||||
|
open: Open
|
||||||
|
finished: Finished
|
||||||
comments:
|
comments:
|
||||||
index:
|
index:
|
||||||
filter: Filter
|
filter: Filter
|
||||||
@@ -96,6 +103,7 @@ en:
|
|||||||
activity: Moderator activity
|
activity: Moderator activity
|
||||||
admin: Admin menu
|
admin: Admin menu
|
||||||
banner: Manage banners
|
banner: Manage banners
|
||||||
|
budgets: Participatory budgets
|
||||||
debate_topics: Debate topics
|
debate_topics: Debate topics
|
||||||
hidden_comments: Hidden comments
|
hidden_comments: Hidden comments
|
||||||
hidden_debates: Hidden debates
|
hidden_debates: Hidden debates
|
||||||
|
|||||||
@@ -58,6 +58,13 @@ es:
|
|||||||
on_users: Usuarios
|
on_users: Usuarios
|
||||||
title: Actividad de los Moderadores
|
title: Actividad de los Moderadores
|
||||||
type: Tipo
|
type: Tipo
|
||||||
|
budgets:
|
||||||
|
index:
|
||||||
|
title: Presupuestos participativos
|
||||||
|
new_link: Crear nuevo
|
||||||
|
filters:
|
||||||
|
open: Abiertos
|
||||||
|
finished: Terminados
|
||||||
comments:
|
comments:
|
||||||
index:
|
index:
|
||||||
filter: Filtro
|
filter: Filtro
|
||||||
@@ -94,6 +101,7 @@ es:
|
|||||||
activity: Actividad de moderadores
|
activity: Actividad de moderadores
|
||||||
admin: Menú de administración
|
admin: Menú de administración
|
||||||
banner: Gestionar banners
|
banner: Gestionar banners
|
||||||
|
budgets: Presupuestos participativos
|
||||||
debate_topics: Temas de debate
|
debate_topics: Temas de debate
|
||||||
hidden_comments: Comentarios ocultos
|
hidden_comments: Comentarios ocultos
|
||||||
hidden_debates: Debates ocultos
|
hidden_debates: Debates ocultos
|
||||||
|
|||||||
@@ -33,6 +33,13 @@ en:
|
|||||||
application:
|
application:
|
||||||
close: Close
|
close: Close
|
||||||
menu: Menu
|
menu: Menu
|
||||||
|
budget:
|
||||||
|
phase:
|
||||||
|
on_hold: On hold
|
||||||
|
accepting: Accepting proposals
|
||||||
|
selecting: Selecting
|
||||||
|
balloting: Balloting
|
||||||
|
finished: Finished
|
||||||
comments:
|
comments:
|
||||||
comment:
|
comment:
|
||||||
admin: Administrator
|
admin: Administrator
|
||||||
|
|||||||
@@ -33,6 +33,13 @@ es:
|
|||||||
application:
|
application:
|
||||||
close: Cerrar
|
close: Cerrar
|
||||||
menu: Menú
|
menu: Menú
|
||||||
|
budget:
|
||||||
|
phase:
|
||||||
|
on_hold: Pausa
|
||||||
|
accepting: Aceptando propuestas
|
||||||
|
selecting: Fase de selección
|
||||||
|
balloting: Fase de Votación
|
||||||
|
finished: Terminado
|
||||||
comments:
|
comments:
|
||||||
comment:
|
comment:
|
||||||
admin: Administrador
|
admin: Administrador
|
||||||
|
|||||||
@@ -153,6 +153,13 @@ Rails.application.routes.draw do
|
|||||||
get :summary, on: :collection
|
get :summary, on: :collection
|
||||||
end
|
end
|
||||||
|
|
||||||
|
resources :budgets do
|
||||||
|
resources :budget_groups do
|
||||||
|
resources :budget_headings do
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
resources :banners, only: [:index, :new, :create, :edit, :update, :destroy] do
|
resources :banners, only: [:index, :new, :create, :edit, :update, :destroy] do
|
||||||
collection { get :search}
|
collection { get :search}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -210,10 +210,10 @@ ActiveRecord::Schema.define(version: 20160617172616) do
|
|||||||
t.string "visit_id"
|
t.string "visit_id"
|
||||||
t.datetime "hidden_at"
|
t.datetime "hidden_at"
|
||||||
t.integer "flags_count", default: 0
|
t.integer "flags_count", default: 0
|
||||||
t.datetime "ignored_flag_at"
|
|
||||||
t.integer "cached_votes_total", default: 0
|
t.integer "cached_votes_total", default: 0
|
||||||
t.integer "cached_votes_up", default: 0
|
t.integer "cached_votes_up", default: 0
|
||||||
t.integer "cached_votes_down", default: 0
|
t.integer "cached_votes_down", default: 0
|
||||||
|
t.datetime "ignored_flag_at"
|
||||||
t.integer "comments_count", default: 0
|
t.integer "comments_count", default: 0
|
||||||
t.datetime "confirmed_hide_at"
|
t.datetime "confirmed_hide_at"
|
||||||
t.integer "cached_anonymous_votes_total", default: 0
|
t.integer "cached_anonymous_votes_total", default: 0
|
||||||
|
|||||||
79
spec/features/admin/budgets_spec.rb
Normal file
79
spec/features/admin/budgets_spec.rb
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
feature 'Admin budgets' do
|
||||||
|
|
||||||
|
background do
|
||||||
|
admin = create(:administrator)
|
||||||
|
login_as(admin.user)
|
||||||
|
end
|
||||||
|
|
||||||
|
context "Feature flag" do
|
||||||
|
|
||||||
|
xscenario 'Disabled with a feature flag' do
|
||||||
|
Setting['feature.budgets'] = nil
|
||||||
|
expect{ visit admin_budgets_path }.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
context "Index" do
|
||||||
|
|
||||||
|
scenario 'Displaying budgets' do
|
||||||
|
budget = create(:budget)
|
||||||
|
visit admin_budgets_path
|
||||||
|
|
||||||
|
expect(page).to have_content(budget.name)
|
||||||
|
expect(page).to have_content(I18n.t("budget.phase.#{budget.phase}"))
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'Filters by phase' do
|
||||||
|
budget1 = create(:budget)
|
||||||
|
budget2 = create(:budget, :accepting)
|
||||||
|
budget3 = create(:budget, :selecting)
|
||||||
|
budget4 = create(:budget, :balloting)
|
||||||
|
budget5 = create(:budget, :finished)
|
||||||
|
|
||||||
|
visit admin_budgets_path
|
||||||
|
expect(page).to have_content(budget1.name)
|
||||||
|
expect(page).to have_content(budget2.name)
|
||||||
|
expect(page).to have_content(budget3.name)
|
||||||
|
expect(page).to have_content(budget4.name)
|
||||||
|
expect(page).to_not have_content(budget5.name)
|
||||||
|
|
||||||
|
click_link "Finished"
|
||||||
|
expect(page).to_not have_content(budget1.name)
|
||||||
|
expect(page).to_not have_content(budget2.name)
|
||||||
|
expect(page).to_not have_content(budget3.name)
|
||||||
|
expect(page).to_not have_content(budget4.name)
|
||||||
|
expect(page).to have_content(budget5.name)
|
||||||
|
|
||||||
|
click_link "Open"
|
||||||
|
expect(page).to have_content(budget1.name)
|
||||||
|
expect(page).to have_content(budget2.name)
|
||||||
|
expect(page).to have_content(budget3.name)
|
||||||
|
expect(page).to have_content(budget4.name)
|
||||||
|
expect(page).to_not have_content(budget5.name)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
scenario "Current filter is properly highlighted" do
|
||||||
|
filters_links = {'open' => 'Open', 'finished' => 'Finished'}
|
||||||
|
|
||||||
|
visit admin_budgets_path
|
||||||
|
|
||||||
|
expect(page).to_not have_link(filters_links.values.first)
|
||||||
|
filters_links.keys.drop(1).each { |filter| expect(page).to have_link(filters_links[filter]) }
|
||||||
|
|
||||||
|
filters_links.each_pair do |current_filter, link|
|
||||||
|
visit admin_budgets_path(filter: current_filter)
|
||||||
|
|
||||||
|
expect(page).to_not have_link(link)
|
||||||
|
|
||||||
|
(filters_links.keys - [current_filter]).each do |filter|
|
||||||
|
expect(page).to have_link(filters_links[filter])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user