Commit a2dbb107 authored by royce-matthew's avatar royce-matthew

added defense items and progressbar

parent 4240cb07
......@@ -26,6 +26,10 @@ module Admin
end
def destroy
@candidate = Candidate.find(params[:id])
@candidate.votes.each do |v|
v.destroy!
end
@candidate.destroy!
redirect_to admin_candidates_path
end
......
......@@ -23,10 +23,27 @@ module Voting
end
def new
@votes= Vote.all
voted_for = false
@pos = params[:id]
Position.find(@pos).candidates.each do |c|
c.votes.each do |v|
if current_user.id == v.user_id
voted_for = true
end
end
end
if voted_for == false
@votes= Vote.all
@vote = Vote.new
render "voting/votes/new.html.erb"
else
redirect_to voting_votes_path
end
end
def create
......
......@@ -35,6 +35,8 @@ o=0
%>
<%end%>
<div class="row">
......@@ -52,3 +54,13 @@ o=0
</div>
<hr>
<%= link_to "Back to Candidates", admin_candidates_path %>
<%@candidate.votes.each do |v|%>
<li><%="#{v.user.email}:"%>
<p style="">Comments: <%=v.comments%>
</p>
</li>
<%end%>
\ No newline at end of file
......@@ -5,9 +5,15 @@
<h4><%=p.name%></h4>
<table style="width:300px;">
<thead><td>Name</td><td>Slogan</td><td>Votes</td></thead>
<%total = 0%>
<%p.candidates.each do |c|%>
<%total = total+c.votes.count%>
<%end%>
<%p.candidates.each do |c|%>
<tr><td><%=link_to c.full_name, admin_candidate_path(c.id), {:style =>"font-size:15 px;"}%></td><td ><%=c.slogan%></td><td><%=c.votes.count%></td></tr>
<tr><td><%=link_to c.full_name, admin_candidate_path(c.id), {:style =>"font-size:15 px;"}%></td><td ><%=c.slogan%></td><td><%=c.votes.count%></td>
<td> <progress value="<%=c.votes.count%>" max="<%=total%>" ></td>
</tr>
<%end%>
</table>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment