Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MIS21FinalsElection
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dean Krisitan Bardeloza
MIS21FinalsElection
Commits
4ea169ae
Commit
4ea169ae
authored
Jul 20, 2016
by
Kristoff Sison
Browse files
Options
Browse Files
Download
Plain Diff
added voting based on candidate id
parents
f07015a9
4a293966
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
49 additions
and
18 deletions
+49
-18
votes_controller.rb
Election/app/controllers/votes_controller.rb
+4
-0
vote.rb
Election/app/models/vote.rb
+1
-1
show.html.erb
Election/app/views/admin/candidates/show.html.erb
+12
-0
show.html.erb
Election/app/views/candidates/show.html.erb
+19
-0
index.html.erb
Election/app/views/pages/index.html.erb
+1
-1
user_profile.html.erb
Election/app/views/votes/user_profile.html.erb
+12
-16
No files found.
Election/app/controllers/votes_controller.rb
View file @
4ea169ae
...
...
@@ -24,7 +24,11 @@ class VotesController < ApplicationController
end
def
profile
@positions
=
Position
.
all
@candidates
=
Candidate
.
all
@user
=
current_user
@votes
=
current_user
.
votes
render
"votes/user_profile.html.erb"
end
private
...
...
Election/app/models/vote.rb
View file @
4ea169ae
...
...
@@ -5,5 +5,5 @@ class Vote < ActiveRecord::Base
def
to_s
"
#{
candidate
.
first_name
}
#{
candidate
.
last_name
}
"
end
accepts_nested_attributes_for
:votes
#
accepts_nested_attributes_for :votes
end
Election/app/views/admin/candidates/show.html.erb
View file @
4ea169ae
...
...
@@ -7,5 +7,17 @@
<li>
Female Voters:
<%=
@votes_female
.
size
%>
</li>
</ul>
<
<<<<<<
HEAD
<%=
link_to
"Votes for Candidate"
,
"/election/vote/
#{
@candidate
.
id
}
"
%>
=======
<
h2
>
People who voted for
<%=
@candidate
.
first_name
%>
<%=
@candidate
.
last_name
%>
:
</h2>
<ul>
<li>
User - Comment
</li>
<%
@votes
.
each
do
|
v
|
%>
<li>
<%=
v
.
user
.
email
%>
-
<%=
v
.
comment
%>
</li>
<%
end
%>
</ul>
>>>>>>> 4a293966901c2565a4eea2574a3086d230d926fc
<%=
link_to
"Back to Candidates"
,
admin_candidates_path
%>
\ No newline at end of file
Election/app/views/candidates/show.html.erb
0 → 100644
View file @
4ea169ae
<h2>
Candidate:
<%=
@candidate
.
first_name
%>
<%=
@candidate
.
last_name
%>
</h2>
<h4>
Party List:
<%=
@candidate
.
party_list
.
name
%>
</h4>
<h3>
<%=
@candidate
.
last_name
%>
's Slogan:
<%=
@candidate
.
slogan
%>
</h3>
<ul>
<li>
Votes:
<%=
@votes_male
.
size
+
@votes_female
.
size
%>
</li>
<li>
Male Voters:
<%=
@votes_male
.
size
%>
</li>
<li>
Female Voters:
<%=
@votes_female
.
size
%>
</li>
</ul>
<h2>
People who voted for
<%=
@candidate
.
first_name
%>
<%=
@candidate
.
last_name
%>
:
</h2>
<ul>
<li>
User - Comment
</li>
<%
@votes
.
each
do
|
v
|
%>
<li>
<%=
v
.
user
.
email
%>
-
<%=
v
.
comment
%>
</li>
<%
end
%>
</ul>
<%=
link_to
"Back to Candidates"
,
admin_candidates_path
%>
\ No newline at end of file
Election/app/views/pages/index.html.erb
View file @
4ea169ae
...
...
@@ -25,7 +25,7 @@
</tr>
<%
p
.
candidates
.
each
do
|
candidate
|
%>
<td>
<%=
candidate
.
first_name
%>
<%=
candidate
.
last_name
%>
</td>
<td>
<%=
candidate
.
votes
.
count
%>
</td>
<td>
<%=
Vote
.
where
(
candidate_id:
candidate
.
id
)
.
count
%>
</td>
<%
end
%>
</table>
<%
end
%>
...
...
Election/app/views/votes/user_profile.html.erb
View file @
4ea169ae
<h1>
Profile Page
</h1>
<h2>
<%=
@user
.
first_name
%>
<%=
@
user
.
last_name
%>
</h2>
<h2>
<%=
current_user
.
id
%>
<%=
current_user
.
first_name
%>
<%=
current_
user
.
last_name
%>
</h2>
<hr>
<table
class=
"table table-striped"
>
<thead>
<th>
Vote ID
</th>
<th>
Candidate Voted
</th>
<th>
Voted on
</th>
</thead>
<tbody>
<%
@votes
.
each
do
|
v
|
%>
<tr>
<td>
<%=
v
.
id
%>
</td>
<td>
<%=
v
.
candidate
.
first_name
%>
"
<%=
v
.
candidate
.
nickname
%>
"
<%=
v
.
candidate
.
last_name
%>
</td>
<td>
<%=
v
.
created_at
%>
</td>
</tr>
<h2>
Positions
</h2>
<%
@positions
.
each
do
|
p
|
%>
<h3>
<%=
p
.
name
%>
</h3>
<%
p
.
candidates
.
each
do
|
c
|
%>
<%
c
.
votes
.
each
do
|
v
|
%>
<%
if
v
.
user_id
==
current_user
.
id
%>
<%=
v
.
candidate
.
first_name
%>
<%=
v
.
candidate
.
last_name
%>
<%=
v
.
comments
%>
<%
else
%>
<%
end
%>
<%
end
%>
</tbody
>
</table
>
<%
end
%
>
<%
end
%
>
<hr>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment