Adds proposal ballots controller and views

This commit is contained in:
Alberto Garcia Cabeza
2016-09-07 12:43:12 +02:00
parent 362f45378c
commit a527de4f92
6 changed files with 149 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
class ProposalBallotsController < ApplicationController
skip_authorization_check
def index
@proposal_ballots = Proposal.successfull.sort_by_confidence_score
end
end

View File

@@ -0,0 +1,3 @@
<div id="<%= dom_id(proposal) %>" class="proposal-sucessfull">
<h3><%= link_to proposal.title, proposal_ballots_path %></h3>
</div>

View File

@@ -0,0 +1,13 @@
<div id="<%= dom_id(proposal) %>" class="proposal-sucessfull">
<h3><%= link_to proposal.title, proposal %></h3>
<h4><%= proposal.question %></h4>
<div class="info">
<% if proposal.author.hidden? || proposal.author.erased? %>
<%= t("proposals.show.author_deleted") %>
<% else %>
<%= proposal.author.name %>
<% end %>
&nbsp;&bull;&nbsp;
<strong><%= t("proposals.proposal.supports", count: proposal.total_votes) %></strong>
</div>
</div>

View File

@@ -0,0 +1,36 @@
<div class="expanded no-margin-top margin-bottom padding successfull-heading">
<div class="row" data-equalizer>
<div class="small-12 medium-8 column" data-equalizer-watch>
<h2>
<%= t("proposal_ballots.title") %>
</h2>
<p>
<%= t("proposal_ballots.description_html",
supports: Setting['votes_for_proposal_success'].to_i).html_safe %>
</p>
</div>
<div class="small-12 medium-4 column info" data-equalizer-watch>
<p><span class="icon-calendar"></span>&nbsp;<%= t("proposal_ballots.date_title") %></p>
<h3><%= t("proposal_ballots.date") %></h3>
</div>
</div>
</div>
<main>
<div class="row">
<div class="small-12 column">
<% if @proposal_ballots.present? %>
<div class="proposals-ballot-list">
<% @proposal_ballots.each do |proposal_for_vote| %>
<%= render "successfull_proposal", proposal: proposal_for_vote %>
<% end %>
</div>
<% else %>
<p>
<%= t("proposal_ballots.nothing_to_vote") %>
</p>
<% end %>
</div>
</div>
</main>

View File

@@ -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

View File

@@ -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