From a527de4f9224dc67a6da675a9d980f2dcc5de7b2 Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Wed, 7 Sep 2016 12:43:12 +0200 Subject: [PATCH] Adds proposal ballots controller and views --- .../proposal_ballots_controller.rb | 8 ++ .../_featured_successfull_proposal.html.erb | 3 + .../_successfull_proposal.html.erb | 13 +++ app/views/proposal_ballots/index.html.erb | 36 ++++++++ config/routes.rb | 2 + db/schema.rb | 87 +++++++++++++++++++ 6 files changed, 149 insertions(+) create mode 100644 app/controllers/proposal_ballots_controller.rb create mode 100644 app/views/proposal_ballots/_featured_successfull_proposal.html.erb create mode 100644 app/views/proposal_ballots/_successfull_proposal.html.erb create mode 100644 app/views/proposal_ballots/index.html.erb diff --git a/app/controllers/proposal_ballots_controller.rb b/app/controllers/proposal_ballots_controller.rb new file mode 100644 index 000000000..4e3e99671 --- /dev/null +++ b/app/controllers/proposal_ballots_controller.rb @@ -0,0 +1,8 @@ +class ProposalBallotsController < ApplicationController + skip_authorization_check + + def index + @proposal_ballots = Proposal.successfull.sort_by_confidence_score + end + +end diff --git a/app/views/proposal_ballots/_featured_successfull_proposal.html.erb b/app/views/proposal_ballots/_featured_successfull_proposal.html.erb new file mode 100644 index 000000000..97754ce9c --- /dev/null +++ b/app/views/proposal_ballots/_featured_successfull_proposal.html.erb @@ -0,0 +1,3 @@ +
+

<%= link_to proposal.title, proposal_ballots_path %>

+
diff --git a/app/views/proposal_ballots/_successfull_proposal.html.erb b/app/views/proposal_ballots/_successfull_proposal.html.erb new file mode 100644 index 000000000..3a8c2a557 --- /dev/null +++ b/app/views/proposal_ballots/_successfull_proposal.html.erb @@ -0,0 +1,13 @@ +
+

<%= link_to proposal.title, proposal %>

+

<%= proposal.question %>

+
+ <% if proposal.author.hidden? || proposal.author.erased? %> + <%= t("proposals.show.author_deleted") %> + <% else %> + <%= proposal.author.name %> + <% end %> +  •  + <%= t("proposals.proposal.supports", count: proposal.total_votes) %> +
+
diff --git a/app/views/proposal_ballots/index.html.erb b/app/views/proposal_ballots/index.html.erb new file mode 100644 index 000000000..6206a856c --- /dev/null +++ b/app/views/proposal_ballots/index.html.erb @@ -0,0 +1,36 @@ +
+
+
+

+ <%= t("proposal_ballots.title") %> +

+

+ <%= t("proposal_ballots.description_html", + supports: Setting['votes_for_proposal_success'].to_i).html_safe %> +

+
+ +
+

 <%= t("proposal_ballots.date_title") %>

+

<%= t("proposal_ballots.date") %>

+
+
+
+ +
+
+
+ <% if @proposal_ballots.present? %> +
+ <% @proposal_ballots.each do |proposal_for_vote| %> + <%= render "successfull_proposal", proposal: proposal_for_vote %> + <% end %> +
+ <% else %> +

+ <%= t("proposal_ballots.nothing_to_vote") %> +

+ <% end %> +
+
+
diff --git a/config/routes.rb b/config/routes.rb index 4f3eb94ec..df1a7c6fb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -61,6 +61,8 @@ Rails.application.routes.draw do end end + resources :proposal_ballots, only: [:index] + resources :comments, only: [:create, :show], shallow: true do member do post :vote diff --git a/db/schema.rb b/db/schema.rb index becde4f8a..6124f31d0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -78,6 +78,91 @@ ActiveRecord::Schema.define(version: 20160803154011) do add_index "banners", ["hidden_at"], name: "index_banners_on_hidden_at", using: :btree + create_table "budget_ballot_lines", force: :cascade do |t| + t.integer "ballot_id" + t.integer "investment_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "budget_id" + t.integer "group_id" + t.integer "heading_id" + end + + add_index "budget_ballot_lines", ["ballot_id"], name: "index_budget_ballot_lines_on_ballot_id", using: :btree + add_index "budget_ballot_lines", ["investment_id"], name: "index_budget_ballot_lines_on_investment_id", using: :btree + + create_table "budget_ballots", force: :cascade do |t| + t.integer "user_id" + t.integer "budget_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "budget_groups", force: :cascade do |t| + t.integer "budget_id" + t.string "name", limit: 50 + end + + add_index "budget_groups", ["budget_id"], name: "index_budget_groups_on_budget_id", using: :btree + + create_table "budget_headings", force: :cascade do |t| + t.integer "budget_id" + t.integer "geozone_id" + t.string "name", limit: 50 + t.integer "price", limit: 8 + end + + create_table "budget_investments", force: :cascade do |t| + t.integer "author_id" + t.integer "administrator_id" + t.string "title" + t.text "description" + t.string "external_url" + t.integer "price", limit: 8 + t.string "feasibility", limit: 15, default: "undecided" + t.text "price_explanation" + t.text "unfeasibility_explanation" + t.text "internal_comments" + t.boolean "valuation_finished", default: false + t.integer "valuator_assignments_count", default: 0 + t.integer "price_first_year", limit: 8 + t.string "duration" + t.datetime "hidden_at" + t.integer "cached_votes_up", default: 0 + t.integer "comments_count", default: 0 + t.integer "confidence_score", default: 0, null: false + t.integer "physical_votes", default: 0 + t.tsvector "tsv" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "heading_id" + t.string "responsible_name" + end + + add_index "budget_investments", ["administrator_id"], name: "index_budget_investments_on_administrator_id", using: :btree + add_index "budget_investments", ["author_id"], name: "index_budget_investments_on_author_id", using: :btree + add_index "budget_investments", ["heading_id"], name: "index_budget_investments_on_heading_id", using: :btree + add_index "budget_investments", ["tsv"], name: "index_budget_investments_on_tsv", using: :gin + + create_table "budget_valuator_assignments", force: :cascade do |t| + t.integer "valuator_id" + t.integer "investment_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "budget_valuator_assignments", ["investment_id"], name: "index_budget_valuator_assignments_on_investment_id", using: :btree + + create_table "budgets", force: :cascade do |t| + t.string "name", limit: 30 + t.text "description" + t.string "currency_symbol", limit: 10 + t.string "phase", limit: 15, default: "on_hold" + t.boolean "valuating", default: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "campaigns", force: :cascade do |t| t.string "name" t.string "track_id" @@ -378,6 +463,7 @@ ActiveRecord::Schema.define(version: 20160803154011) do t.integer "proposals_count", default: 0 t.integer "spending_proposals_count", default: 0 t.string "kind" + t.integer "budget/investments_count", default: 0 end add_index "tags", ["debates_count"], name: "index_tags_on_debates_count", using: :btree @@ -484,6 +570,7 @@ ActiveRecord::Schema.define(version: 20160803154011) do t.integer "user_id" t.string "description" t.integer "spending_proposals_count", default: 0 + t.integer "budget_investments_count", default: 0 end add_index "valuators", ["user_id"], name: "index_valuators_on_user_id", using: :btree