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
05665016
Commit
05665016
authored
Jul 21, 2016
by
Dean Krisitan Bardeloza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modified candidates controller and show
parent
6c976fe2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
6 deletions
+23
-6
candidates_controller.rb
Election/app/controllers/admin/candidates_controller.rb
+8
-1
candidates_controller.rb
Election/app/controllers/candidates_controller.rb
+7
-0
show.html.erb
Election/app/views/admin/candidates/show.html.erb
+4
-2
show.html.erb
Election/app/views/candidates/show.html.erb
+4
-3
No files found.
Election/app/controllers/admin/candidates_controller.rb
View file @
05665016
...
...
@@ -45,6 +45,13 @@ class CandidatesController < ApplicationController
@votes_female
.
push
(
vote
)
end
end
if
@votes
.
size
==
0
@percent_male
=
0
@percent_female
=
0
else
@percent_male
=
@votes_male
.
size
*
100
/
@votes
.
size
@percent_female
=
@votes_female
.
size
*
100
/
@votes
.
size
end
end
def
destroy
@candidate
=
Candidate
.
find
(
params
[
:id
])
...
...
Election/app/controllers/candidates_controller.rb
View file @
05665016
...
...
@@ -20,4 +20,11 @@ class CandidatesController < ApplicationController
end
end
end
if
@votes
.
size
==
0
@percent_male
=
0
@percent_female
=
0
else
@percent_male
=
@votes_male
.
size
*
100
/
@votes
.
size
@percent_female
=
@votes_female
.
size
*
100
/
@votes
.
size
end
end
\ No newline at end of file
Election/app/views/admin/candidates/show.html.erb
View file @
05665016
...
...
@@ -2,10 +2,12 @@
<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
%>
(
<%=
@
votes_male
.
size
*
100
/
@votes
.
siz
e
%>
%)
</li>
<li>
Female Voters:
<%=
@votes_female
.
size
%>
(
<%=
@
votes_female
.
size
*
100
/
@votes
.
siz
e
%>
%)
</li>
<li>
Male Voters:
<%=
@votes_male
.
size
%>
(
<%=
@
percent_mal
e
%>
%)
</li>
<li>
Female Voters:
<%=
@votes_female
.
size
%>
(
<%=
@
percent_femal
e
%>
%)
</li>
</ul>
<%
else
%>
<h1>
<%=
"You do not have acces to this feature"
%>
</h1>
...
...
Election/app/views/candidates/show.html.erb
View file @
05665016
...
...
@@ -3,8 +3,8 @@
<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
%>
(
<%=
@
votes_male
.
size
*
100
/
@votes
.
siz
e
%>
%)
</li>
<li>
Female Voters:
<%=
@votes_female
.
size
%>
(
<%=
@
votes_female
.
size
*
100
/
@votes
.
siz
e
%>
%)
</li>
<li>
Male Voters:
<%=
@votes_male
.
size
%>
(
<%=
@
percent_mal
e
%>
%)
</li>
<li>
Female Voters:
<%=
@votes_female
.
size
%>
(
<%=
@
percent_femal
e
%>
%)
</li>
</ul>
<h2>
People who voted for
<%=
@candidate
.
first_name
%>
<%=
@candidate
.
last_name
%>
:
</h2>
...
...
@@ -17,3 +17,4 @@
<%
end
%>
</ul>
<%=
link_to
"Back to Candidates"
,
candidates_path
%>
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