From 73df3d12587bbfa00337b40dd51e91ae437e607b Mon Sep 17 00:00:00 2001 From: Mark Moser Date: Sun, 4 Dec 2016 16:19:16 -0600 Subject: [PATCH] lock voting when interview status not pending --- app/views/admin/result/_voting.html.erb | 19 ++++++++++++++----- .../20161204213828_remove_vote_locking.rb | 6 ++++++ db/schema.rb | 1 - 3 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 db/migrate/20161204213828_remove_vote_locking.rb diff --git a/app/views/admin/result/_voting.html.erb b/app/views/admin/result/_voting.html.erb index 3c89df9..42316c5 100644 --- a/app/views/admin/result/_voting.html.erb +++ b/app/views/admin/result/_voting.html.erb @@ -3,12 +3,21 @@ <% if current_user.acts_as_reviewer? %>
Votes: - <%= link_to admin_up_vote_path(test_hash: @candidate.test_hash), remote: true do %> - Yea (<%= @candidate.votes.yea.count %>) - <% end %> - <%= link_to admin_down_vote_path(test_hash: @candidate.test_hash), remote: true do %> - Nay (<%= @candidate.votes.nay.count %>) + + <% if @candidate.pending? %> + <%= link_to admin_up_vote_path(test_hash: @candidate.test_hash), remote: true do %> + Yea (<%= @candidate.votes.yea.count %>) + <% end %> + + <%= link_to admin_down_vote_path(test_hash: @candidate.test_hash), remote: true do %> + Nay (<%= @candidate.votes.nay.count %>) + <% end %> + <% else %> + Voting closed - + Yea (<%= @candidate.votes.yea.count %>) - + Nay (<%= @candidate.votes.nay.count %>) <% end %> + (Your vote: <%= current_user.my_vote(@candidate) %>)
<% end %> diff --git a/db/migrate/20161204213828_remove_vote_locking.rb b/db/migrate/20161204213828_remove_vote_locking.rb new file mode 100644 index 0000000..b842e74 --- /dev/null +++ b/db/migrate/20161204213828_remove_vote_locking.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true +class RemoveVoteLocking < ActiveRecord::Migration[5.0] + def change + remove_column :reviewer_votes, :locked, :boolean, default: false, null: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 2126b30..912be6d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -80,7 +80,6 @@ ActiveRecord::Schema.define(version: 20161120175737) do t.integer "vote", default: 0, null: false t.integer "veto", default: 0, null: false t.datetime "last_reminded" - t.boolean "locked", default: false, null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["candidate_id", "user_id"], name: "index_reviewer_votes_on_candidate_id_and_user_id", unique: true, using: :btree