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: