diff --git a/app/controllers/admin/proposals_controller.rb b/app/controllers/admin/proposals_controller.rb new file mode 100644 index 000000000..64b5e3526 --- /dev/null +++ b/app/controllers/admin/proposals_controller.rb @@ -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 diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index 5344c06f8..6e393e805 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -79,6 +79,15 @@ <% end %> + <% if feature?(:proposals) %> +
  • + <%= link_to admin_proposals_path do %> + + <%= t("admin.menu.proposals") %> + <% end %> +
  • + <% end %> + <% messages_sections = %w(newsletters emails_download admin_notifications system_emails) %> <% messages_menu_active = messages_sections.include?(controller_name) %>
  • > diff --git a/app/views/admin/proposals/index.html.erb b/app/views/admin/proposals/index.html.erb new file mode 100644 index 000000000..181674b73 --- /dev/null +++ b/app/views/admin/proposals/index.html.erb @@ -0,0 +1,37 @@ +<% provide(:title) do %> + <%= t("admin.header.title") %> - <%= t("admin.proposals.index.title") %> +<% end %> + +

    <%= t("admin.proposals.index.title") %>

    + +<% if @proposals.any? %> +

    <%= page_entries_info @proposals %>

    + + + + + + + + + + + + + <% @proposals.each do |proposal| %> + + + + + + + <% end %> + +
    <%= t("admin.proposals.index.id") %><%= t("admin.proposals.index.title") %><%= t("admin.proposals.index.author") %><%= t("admin.proposals.index.milestones") %>
    <%= proposal.id %><%= link_to proposal.title, admin_proposal_path(proposal) %><%= proposal.author.username %><%= proposal.milestones.count %>
    + + <%= paginate @proposals %> +<% else %> +
    + <%= t("admin.proposals.index.no_proposals") %> +
    +<% end %> diff --git a/app/views/admin/proposals/show.html.erb b/app/views/admin/proposals/show.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 0fd2a0d56..cd99283ce 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -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 diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index 5798dd0b1..cc0d99b7e 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -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 diff --git a/config/routes/admin.rb b/config/routes/admin.rb index a6ccf2de3..660d90e3c 100644 --- a/config/routes/admin.rb +++ b/config/routes/admin.rb @@ -29,6 +29,8 @@ namespace :admin do end end + resources :proposals, only: [:index, :show] + resources :hidden_proposals, only: :index do member do put :restore diff --git a/spec/features/admin/proposals_spec.rb b/spec/features/admin/proposals_spec.rb new file mode 100644 index 000000000..305db9d6c --- /dev/null +++ b/spec/features/admin/proposals_spec.rb @@ -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 diff --git a/spec/features/admin/site_customization/information_texts_spec.rb b/spec/features/admin/site_customization/information_texts_spec.rb index 454a83526..83e4edb9a 100644 --- a/spec/features/admin/site_customization/information_texts_spec.rb +++ b/spec/features/admin/site_customization/information_texts_spec.rb @@ -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