Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
candi-date-tayo
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
George Nicole Balmaceda
candi-date-tayo
Commits
a2dbb107
Commit
a2dbb107
authored
Jul 19, 2016
by
royce-matthew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added defense items and progressbar
parent
4240cb07
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
2 deletions
+41
-2
candidates_controller.rb
app/controllers/admin/candidates_controller.rb
+4
-0
votes_controller.rb
app/controllers/voting/votes_controller.rb
+18
-1
show.html.erb
app/views/admin/candidates/show.html.erb
+12
-0
index.html.erb
app/views/pages/index.html.erb
+7
-1
No files found.
app/controllers/admin/candidates_controller.rb
View file @
a2dbb107
...
...
@@ -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
...
...
app/controllers/voting/votes_controller.rb
View file @
a2dbb107
...
...
@@ -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
...
...
app/views/admin/candidates/show.html.erb
View file @
a2dbb107
...
...
@@ -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
app/views/pages/index.html.erb
View file @
a2dbb107
...
...
@@ -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>
...
...
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