Add proposals index in admin

This commit is contained in:
Javi Martín
2018-11-15 13:38:06 +01:00
parent 7891efee32
commit 4770217373
9 changed files with 94 additions and 2 deletions

View File

@@ -0,0 +1,12 @@
class Admin::ProposalsController < Admin::BaseController
include FeatureFlags
feature_flag :proposals
def index
@proposals = Proposal.sort_by_created_at.page(params[:page])
end
def show
@proposal = Proposal.find(params[:id])
end
end

View File

@@ -79,6 +79,15 @@
</li> </li>
<% end %> <% end %>
<% if feature?(:proposals) %>
<li class="section-title">
<%= link_to admin_proposals_path do %>
<span class="icon-proposals"></span>
<strong><%= t("admin.menu.proposals") %></strong>
<% end %>
</li>
<% end %>
<% messages_sections = %w(newsletters emails_download admin_notifications system_emails) %> <% messages_sections = %w(newsletters emails_download admin_notifications system_emails) %>
<% messages_menu_active = messages_sections.include?(controller_name) %> <% messages_menu_active = messages_sections.include?(controller_name) %>
<li class="section-title" <%= "class=is-active" if messages_menu_active %>> <li class="section-title" <%= "class=is-active" if messages_menu_active %>>

View File

@@ -0,0 +1,37 @@
<% provide(:title) do %>
<%= t("admin.header.title") %> - <%= t("admin.proposals.index.title") %>
<% end %>
<h2><%= t("admin.proposals.index.title") %></h2>
<% if @proposals.any? %>
<h3><%= page_entries_info @proposals %></h3>
<table>
<thead>
<tr>
<th class="text-center"><%= t("admin.proposals.index.id") %></th>
<th><%= t("admin.proposals.index.title") %></th>
<th><%= t("admin.proposals.index.author") %></th>
<th><%= t("admin.proposals.index.milestones") %></th>
</tr>
</thead>
<tbody>
<% @proposals.each do |proposal| %>
<tr id="<%= dom_id(proposal) %>" class="proposal">
<td class="text-center"><%= proposal.id %></td>
<td><%= link_to proposal.title, admin_proposal_path(proposal) %></td>
<td><%= proposal.author.username %></td>
<td><%= proposal.milestones.count %></td>
</tr>
<% end %>
</tbody>
</table>
<%= paginate @proposals %>
<% else %>
<div class="callout primary">
<%= t("admin.proposals.index.no_proposals") %>
</div>
<% end %>

View File

View File

@@ -536,6 +536,7 @@ en:
admin: Admin menu admin: Admin menu
banner: Manage banners banner: Manage banners
poll_questions: Questions poll_questions: Questions
proposals: Proposals
proposals_topics: Proposals topics proposals_topics: Proposals topics
budgets: Participatory budgets budgets: Participatory budgets
geozones: Manage geozones geozones: Manage geozones
@@ -1040,6 +1041,13 @@ en:
search: search:
title: Search Organisations title: Search Organisations
no_results: No organizations found. no_results: No organizations found.
proposals:
index:
title: Proposals
id: ID
author: Author
milestones: Milestones
no_proposals: There are no proposals.
hidden_proposals: hidden_proposals:
index: index:
filter: Filter filter: Filter

View File

@@ -532,6 +532,7 @@ es:
admin: Menú de administración admin: Menú de administración
banner: Gestionar banners banner: Gestionar banners
poll_questions: Preguntas poll_questions: Preguntas
proposals: Propuestas
proposals_topics: Temas de propuestas proposals_topics: Temas de propuestas
budgets: Presupuestos participativos budgets: Presupuestos participativos
geozones: Gestionar distritos geozones: Gestionar distritos
@@ -1036,6 +1037,13 @@ es:
search: search:
title: Buscar Organizaciones title: Buscar Organizaciones
no_results: No se han encontrado organizaciones. no_results: No se han encontrado organizaciones.
proposals:
index:
title: Propuestas
id: ID
author: Autor
milestones: Hitos
no_proposals: No hay propuestas.
hidden_proposals: hidden_proposals:
index: index:
filter: Filtro filter: Filtro

View File

@@ -29,6 +29,8 @@ namespace :admin do
end end
end end
resources :proposals, only: [:index, :show]
resources :hidden_proposals, only: :index do resources :hidden_proposals, only: :index do
member do member do
put :restore put :restore

View File

@@ -0,0 +1,16 @@
require "rails_helper"
feature "Admin proposals" do
background do
login_as create(:administrator).user
end
scenario "Index" do
create(:proposal, title: "Make Pluto a planet again")
visit admin_root_path
within("#side_menu") { click_link "Proposals" }
expect(page).to have_content "Make Pluto a planet again"
end
end

View File

@@ -21,7 +21,7 @@ feature "Admin custom information texts" do
click_link 'Community' click_link 'Community'
expect(page).to have_content 'Access the community' expect(page).to have_content 'Access the community'
click_link 'Proposals' within("#information-texts-tabs") { click_link "Proposals" }
expect(page).to have_content 'Create proposal' expect(page).to have_content 'Create proposal'
within "#information-texts-tabs" do within "#information-texts-tabs" do
@@ -49,7 +49,7 @@ feature "Admin custom information texts" do
scenario 'check that tabs are highlight when click it' do scenario 'check that tabs are highlight when click it' do
visit admin_site_customization_information_texts_path visit admin_site_customization_information_texts_path
click_link 'Proposals' within("#information-texts-tabs") { click_link "Proposals" }
expect(find("a[href=\"/admin/site_customization/information_texts?tab=proposals\"].is-active")) expect(find("a[href=\"/admin/site_customization/information_texts?tab=proposals\"].is-active"))
.to have_content "Proposals" .to have_content "Proposals"
end end