Added possibility for Admins to check on votes wo querying the database manually

This commit is contained in:
Absurdon 2017-03-24 00:07:39 +01:00
parent c882419af2
commit 624da53bb6
4 changed files with 25 additions and 1 deletions

View file

@ -48,6 +48,10 @@ class PollsController < ApplicationController
redirect_to polls_url
end
def showvotes
raise AccessError unless cuser.admin?
end
private
def get_poll

View file

@ -1 +1,4 @@
<%= render :partial => "show" %>
<%= render :partial => "show" %>
<% if cuser && cuser.admin? %>
<%= link_to "Show votes", polls_showvotes_url(@poll) ,class: "button" %>
<% end %>

View file

@ -0,0 +1,16 @@
<div>
<h1><%= @poll.question %></h1>
<table>
<tr>
<th>Player</th>
<th>voted for</th>
<th>Time</th>
</tr>
<% @poll.real_votes.reverse_each do |vote| %>
<tr>
<td><%= namelink vote.user %></td>
<td><%= vote.votable%></td>
</tr>
<% end %>
</table>
</div>

View file

@ -130,6 +130,7 @@ Ensl::Application.routes.draw do
match "users/forgot", to: "users#forgot"
match "votes/create"
match "polls/showvotes/:id", to: "polls#showvotes", as: "polls_showvotes"
match ":controller/:action", requirements: { action: /A-Za-z/ }
match ":controller/:action/:id"