From e26b6db584971eb9689109ca582cb17c46650c6b Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Fri, 23 Dec 2016 13:48:34 +0100 Subject: [PATCH 1/4] changes text on poll booths admin menu --- config/locales/admin.en.yml | 2 +- config/locales/admin.es.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index 87a8cc75f..590d54984 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -106,7 +106,7 @@ en: valuators: Valuators poll_officers: Poll officers polls: Polls - poll_booths: Booths + poll_booths: Booths location officials: Officials organizations: Organisations settings: Configuration settings diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index 183597625..c99976086 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -106,7 +106,7 @@ es: valuators: Evaluadores poll_officers: Presidentes de mesa polls: Votaciones - poll_booths: Urnas + poll_booths: Ubicación de urnas officials: Cargos públicos organizations: Organizaciones settings: Configuración global From c0c76b67c23500a498efd7ddcb9ebed9621cd494 Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Fri, 23 Dec 2016 14:16:29 +0100 Subject: [PATCH 2/4] adds successful proposals list on admin questions index --- .../admin/poll/questions_controller.rb | 6 ++++ .../poll/questions/_filter_subnav.html.erb | 12 ++++++++ .../admin/poll/questions/_questions.html.erb | 23 +++++++++++++++ .../questions/_successful_proposals.html.erb | 20 +++++++++++++ app/views/admin/poll/questions/index.html.erb | 28 ++++++------------- config/locales/admin.en.yml | 3 ++ config/locales/admin.es.yml | 3 ++ 7 files changed, 75 insertions(+), 20 deletions(-) create mode 100644 app/views/admin/poll/questions/_filter_subnav.html.erb create mode 100644 app/views/admin/poll/questions/_questions.html.erb create mode 100644 app/views/admin/poll/questions/_successful_proposals.html.erb diff --git a/app/controllers/admin/poll/questions_controller.rb b/app/controllers/admin/poll/questions_controller.rb index 3b23ec21d..e416dfed9 100644 --- a/app/controllers/admin/poll/questions_controller.rb +++ b/app/controllers/admin/poll/questions_controller.rb @@ -9,6 +9,8 @@ class Admin::Poll::QuestionsController < Admin::BaseController @search = search_params[:search] @questions = @questions.search(search_params).page(params[:page]).order("created_at DESC") + + @proposals = Proposal.successful.sort_by_confidence_score end def new @@ -51,6 +53,10 @@ class Admin::Poll::QuestionsController < Admin::BaseController redirect_to admin_questions_path, notice: notice end + def successful? + total_votes >= Proposal.votes_needed_for_success + end + private def load_geozones diff --git a/app/views/admin/poll/questions/_filter_subnav.html.erb b/app/views/admin/poll/questions/_filter_subnav.html.erb new file mode 100644 index 000000000..7f641d390 --- /dev/null +++ b/app/views/admin/poll/questions/_filter_subnav.html.erb @@ -0,0 +1,12 @@ + diff --git a/app/views/admin/poll/questions/_questions.html.erb b/app/views/admin/poll/questions/_questions.html.erb new file mode 100644 index 000000000..f8fc13302 --- /dev/null +++ b/app/views/admin/poll/questions/_questions.html.erb @@ -0,0 +1,23 @@ +
+ <%= render 'filter' %> +
+ +<% if @questions.count == 0 %> +
+ <%= t('admin.questions.index.no_questions') %> +
+<% else %> + + <% @questions.each do |question| %> + + + + + <% end %> +
<%= link_to question.title, admin_question_path(question) %> + <%= link_to t('shared.edit'), edit_admin_question_path(question), class: "button hollow" %> + <%= link_to t('shared.delete'), admin_question_path(question), class: "button hollow alert", method: :delete %> +
+ + <%= paginate @questions %> +<% end %> diff --git a/app/views/admin/poll/questions/_successful_proposals.html.erb b/app/views/admin/poll/questions/_successful_proposals.html.erb new file mode 100644 index 000000000..39d0ea7dc --- /dev/null +++ b/app/views/admin/poll/questions/_successful_proposals.html.erb @@ -0,0 +1,20 @@ + + + <% @proposals.each do |proposal| %> + + + + + <% end %> + +
+ <%= link_to proposal.title, proposal_path(proposal) %> +

+ <%= proposal.summary %>
+ <%= proposal.question %> +

+
+ <%= link_to t("admin.questions.index.create_question"), + new_admin_question_path(proposal_id: proposal.id), + class: "button hollow" %> +
diff --git a/app/views/admin/poll/questions/index.html.erb b/app/views/admin/poll/questions/index.html.erb index 64e22dd2d..f45497af0 100644 --- a/app/views/admin/poll/questions/index.html.erb +++ b/app/views/admin/poll/questions/index.html.erb @@ -9,26 +9,14 @@ -
- <%= render 'filter' %> -
+
+ <%= render "filter_subnav" %> -<% if @questions.count == 0 %> -
- <%= t('admin.questions.index.no_questions') %> +
+ <%= render "questions" %>
-<% else %> - - <% @questions.each do |question| %> - - - - - <% end %> -
<%= link_to question.title, admin_question_path(question) %> - <%= link_to t('shared.edit'), edit_admin_question_path(question), class: "button hollow" %> - <%= link_to t('shared.delete'), admin_question_path(question), class: "button hollow alert", method: :delete %> -
- <%= paginate @questions %> -<% end %> \ No newline at end of file +
+ <%= render "successful_proposals" %> +
+
diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index 590d54984..4e2c63c32 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -200,6 +200,9 @@ en: no_questions: "There are no questions." filter_poll: Filter by Poll select_poll: Select Poll + questions_tab: "Questions" + successful_proposals_tab: "Successful proposals" + create_question: "Create question" edit: title: "Edit Question" new: diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index c99976086..64cde3f8d 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -200,6 +200,9 @@ es: no_questions: "No hay ninguna pregunta ciudadana." filter_poll: "Filtrar por votación" select_poll: "Seleccionar votación" + questions_tab: "Preguntas ciudadanas" + successful_proposals_tab: "Propuestas que han superado el umbral" + create_question: "Crear pregunta para votación" edit: title: "Editar pregunta ciudadana" new: From dc27514fa7291eeaa7b76e1ff92f1e589909c1f9 Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Fri, 23 Dec 2016 14:41:42 +0100 Subject: [PATCH 3/4] updates texts on specs --- spec/features/admin/poll/booths_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/features/admin/poll/booths_spec.rb b/spec/features/admin/poll/booths_spec.rb index b84e32b74..ec8c10d58 100644 --- a/spec/features/admin/poll/booths_spec.rb +++ b/spec/features/admin/poll/booths_spec.rb @@ -11,7 +11,7 @@ feature 'Admin booths' do visit admin_root_path within('#side_menu') do - click_link "Booths" + click_link "Booths location" end expect(page).to have_content "There are no booths" @@ -23,7 +23,7 @@ feature 'Admin booths' do visit admin_root_path within('#side_menu') do - click_link "Booths" + click_link "Booths location" end booths = Poll::Booth.all From 082c48326990a0c2ae7ecdd71a8bc4cd8a2e6364 Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Fri, 23 Dec 2016 18:31:45 +0100 Subject: [PATCH 4/4] removes unnecessary method on questions controller --- app/controllers/admin/poll/questions_controller.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/controllers/admin/poll/questions_controller.rb b/app/controllers/admin/poll/questions_controller.rb index e416dfed9..b7b16e379 100644 --- a/app/controllers/admin/poll/questions_controller.rb +++ b/app/controllers/admin/poll/questions_controller.rb @@ -53,10 +53,6 @@ class Admin::Poll::QuestionsController < Admin::BaseController redirect_to admin_questions_path, notice: notice end - def successful? - total_votes >= Proposal.votes_needed_for_success - end - private def load_geozones