Add proposals index in admin
This commit is contained in:
12
app/controllers/admin/proposals_controller.rb
Normal file
12
app/controllers/admin/proposals_controller.rb
Normal 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
|
||||
@@ -79,6 +79,15 @@
|
||||
</li>
|
||||
<% 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_menu_active = messages_sections.include?(controller_name) %>
|
||||
<li class="section-title" <%= "class=is-active" if messages_menu_active %>>
|
||||
|
||||
37
app/views/admin/proposals/index.html.erb
Normal file
37
app/views/admin/proposals/index.html.erb
Normal 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 %>
|
||||
0
app/views/admin/proposals/show.html.erb
Normal file
0
app/views/admin/proposals/show.html.erb
Normal file
@@ -536,6 +536,7 @@ en:
|
||||
admin: Admin menu
|
||||
banner: Manage banners
|
||||
poll_questions: Questions
|
||||
proposals: Proposals
|
||||
proposals_topics: Proposals topics
|
||||
budgets: Participatory budgets
|
||||
geozones: Manage geozones
|
||||
@@ -1040,6 +1041,13 @@ en:
|
||||
search:
|
||||
title: Search Organisations
|
||||
no_results: No organizations found.
|
||||
proposals:
|
||||
index:
|
||||
title: Proposals
|
||||
id: ID
|
||||
author: Author
|
||||
milestones: Milestones
|
||||
no_proposals: There are no proposals.
|
||||
hidden_proposals:
|
||||
index:
|
||||
filter: Filter
|
||||
|
||||
@@ -532,6 +532,7 @@ es:
|
||||
admin: Menú de administración
|
||||
banner: Gestionar banners
|
||||
poll_questions: Preguntas
|
||||
proposals: Propuestas
|
||||
proposals_topics: Temas de propuestas
|
||||
budgets: Presupuestos participativos
|
||||
geozones: Gestionar distritos
|
||||
@@ -1036,6 +1037,13 @@ es:
|
||||
search:
|
||||
title: Buscar 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:
|
||||
index:
|
||||
filter: Filtro
|
||||
|
||||
@@ -29,6 +29,8 @@ namespace :admin do
|
||||
end
|
||||
end
|
||||
|
||||
resources :proposals, only: [:index, :show]
|
||||
|
||||
resources :hidden_proposals, only: :index do
|
||||
member do
|
||||
put :restore
|
||||
|
||||
16
spec/features/admin/proposals_spec.rb
Normal file
16
spec/features/admin/proposals_spec.rb
Normal 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
|
||||
@@ -21,7 +21,7 @@ feature "Admin custom information texts" do
|
||||
click_link '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'
|
||||
|
||||
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
|
||||
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"))
|
||||
.to have_content "Proposals"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user