Commit 4d85676a authored by Galen Evilla's avatar Galen Evilla

added something

parent e955b633
module Users module Users
class ProfileController < ApplicationController class UsersController < ApplicationController
before_action :authenticate_user! before_action :authenticate_user!
def index def index
@positions = Position.all @positions = Position.all
......
...@@ -6,11 +6,10 @@ ...@@ -6,11 +6,10 @@
<% @positions.each do |p| %> <% @positions.each do |p| %>
<h2><%= p.name %></h2>
<h5><%= p.name %></h5> <ul>
<ul >
<% p.candidates.each do |c|%> <% p.candidates.each do |c|%>
<li><%=link_to c.full_name, admin_candidate_path(c.id)%></li> <li><%=link_to c.full_name, admin_candidate_path(c.id)%></li>
<% end %> <% end %>
</ul> </ul>
<% end %> <% end %>
...@@ -3,12 +3,11 @@ ...@@ -3,12 +3,11 @@
<%=link_to "Add New Position", new_admin_position_path%> <%=link_to "Add New Position", new_admin_position_path%>
<hr> <hr>
<% @positions.each do |c| %> <% @positions.each do |p| %>
<h2>(<%= c.id %>) <%= c.name %></h2> <h2><%= link_to p.name, admin_position_path(p.id) %></h2>
<ul> <ul>
<% c.candidates.each do |p| %> <% p.candidates.each do |c|%>
<li><%= link_to "#{p.first_name} #{p.last_name}" , admin_candidate_path(p.id) %></li> <li><%=link_to c.full_name, admin_candidate_path(c.id)%></li>
<% end %> <% end %>
</ul> </ul>
<% end %> <% end %>
\ No newline at end of file
<h1><%= @position.name%></h1> <h1><%= @position.name%></h1>
<%=link_to "Edit", edit_admin_position_path(@position.id)%> <%=link_to "Edit", edit_admin_position_path(@position.id)%>
<br>
<%=link_to "Delete", admin_position_path(@position.id), method: :delete%> <%=link_to "Delete", admin_position_path(@position.id), method: :delete%>
<br> <br>
<hr>
<h2>Candidates for <%=@position.name%></h2>
<h5>Candidates for <%=@position.name%></h5>
<ul> <ul>
<%@position.candidates.each do |c|%> <%@position.candidates.each do |c|%>
<li><%=link_to c.full_name, admin_candidate_path(c.id)%></li> <li><%=link_to c.full_name, admin_candidate_path(c.id)%></li>
......
...@@ -13,27 +13,20 @@ ...@@ -13,27 +13,20 @@
<%@positions.each do |p|%> <%@positions.each do |p|%>
<h4><%=p.name%></h4> <h4><%=p.name%></h4>
<table> <table class="table table-striped table-bordered">
<thead> <tr>
<td>&nbsp;</td> <th>Name</th>
<td>Name</td> <th>Slogan</th>
<td>Slogan</td> <th>Total Votes</th>
<td>Votes</td>
<td>&nbsp;</td> </tr>
</thead> <%total = 0%>
<%total = 0%> <%p.candidates.each do |c|%>
<%p.candidates.each do |c|%> <tr>
<%total = total+c.votes.count%> <td><%=link_to c.full_name, admin_candidate_path(c.id)%></td>
<%end%> <td><%=c.slogan%></td>
<%p.candidates.each do |c|%> <td><%=c.votes.count%> <progress value="<%=c.votes.count%>" max="<%=total%>" ></td>
</tr>
<tr> <%end%>
<td></td> </table>
<td><%=link_to c.full_name, admin_candidate_path(c.id)%></td>
<td><%=c.slogan%></td>
<td><%=c.votes.count%></td>
<td><progress value="<%=c.votes.count%>" max="<%=total%>" ></td>
</tr>
<%end%>
</table>
<%end%> <%end%>
\ No newline at end of file
...@@ -5,7 +5,7 @@ Rails.application.routes.draw do ...@@ -5,7 +5,7 @@ Rails.application.routes.draw do
resources :users resources :users
get "/profile", to: "users/profile#index" get "/profile", to: "users/users#index"
get "/voting/new/:id", to: "voting/votes#new" get "/voting/new/:id", to: "voting/votes#new"
get "/about" => "pages#about", as: :about get "/about" => "pages#about", as: :about
......
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