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
0c21c196
Commit
0c21c196
authored
Jul 21, 2016
by
Bianca Tarun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed votes form and controller
parent
4d236ef5
Changes
24
Show whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
86 additions
and
123 deletions
+86
-123
Gemfile
Election/Gemfile
+1
-0
Gemfile.lock
Election/Gemfile.lock
+6
-0
election_controller.rb
Election/app/controllers/election_controller.rb
+0
-9
party_lists_controller.rb
Election/app/controllers/party_lists_controller.rb
+1
-0
votes_controller.rb
Election/app/controllers/votes_controller.rb
+5
-16
candidate.rb
Election/app/models/candidate.rb
+3
-1
party_list.rb
Election/app/models/party_list.rb
+1
-0
user.rb
Election/app/models/user.rb
+1
-0
vote.rb
Election/app/models/vote.rb
+1
-1
_form.html.erb
Election/app/views/admin/candidates/_form.html.erb
+2
-2
index.html.erb
Election/app/views/admin/candidates/index.html.erb
+4
-7
show.html.erb
Election/app/views/admin/candidates/show.html.erb
+0
-14
index.html.erb
Election/app/views/admin/party_lists/index.html.erb
+12
-20
show.html.erb
Election/app/views/admin/party_lists/show.html.erb
+1
-1
index.html.erb
Election/app/views/admin/positions/index.html.erb
+1
-1
index.html.erb
Election/app/views/candidates/index.html.erb
+1
-0
show.html.erb
Election/app/views/candidates/show.html.erb
+1
-1
index.html.erb
Election/app/views/pages/index.html.erb
+2
-1
index.html.erb
Election/app/views/party_lists/index.html.erb
+7
-5
_form.html.erb
Election/app/views/votes/_form.html.erb
+30
-7
index.html.erb
Election/app/views/votes/index.html.erb
+3
-1
show.html.erb
Election/app/views/votes/show.html.erb
+0
-32
user_profile.html.erb
Election/app/views/votes/user_profile.html.erb
+3
-3
routes.rb
Election/config/routes.rb
+0
-1
No files found.
Election/Gemfile
View file @
0c21c196
...
@@ -49,3 +49,4 @@ gem 'simple_form'
...
@@ -49,3 +49,4 @@ gem 'simple_form'
gem
'devise'
gem
'devise'
gem
'better_errors'
\ No newline at end of file
Election/Gemfile.lock
View file @
0c21c196
...
@@ -38,10 +38,15 @@ GEM
...
@@ -38,10 +38,15 @@ GEM
tzinfo (~> 1.1)
tzinfo (~> 1.1)
arel (6.0.3)
arel (6.0.3)
bcrypt (3.1.11-x86-mingw32)
bcrypt (3.1.11-x86-mingw32)
better_errors (2.1.1)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
rack (>= 0.9.0)
binding_of_caller (0.7.2)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
debug_inspector (>= 0.0.1)
builder (3.2.2)
builder (3.2.2)
byebug (9.0.5)
byebug (9.0.5)
coderay (1.1.1)
coffee-rails (4.1.1)
coffee-rails (4.1.1)
coffee-script (>= 2.2.0)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.1.x)
railties (>= 4.0.0, < 5.1.x)
...
@@ -162,6 +167,7 @@ PLATFORMS
...
@@ -162,6 +167,7 @@ PLATFORMS
x86-mingw32
x86-mingw32
DEPENDENCIES
DEPENDENCIES
better_errors
byebug
byebug
coffee-rails (~> 4.1.0)
coffee-rails (~> 4.1.0)
devise
devise
...
...
Election/app/controllers/election_controller.rb
deleted
100644 → 0
View file @
4d236ef5
class
ElectionController
<
ApplicationController
def
vote
if
Vote
.
exists?
(
candidate_id:
params
[
:id
],
user_id:
current_user
.
id
)
render
"candidates/show.html.erb"
else
redirect_to
new_vote_path
end
end
end
\ No newline at end of file
Election/app/controllers/party_lists_controller.rb
View file @
0c21c196
...
@@ -3,6 +3,7 @@ class PartyListsController < ApplicationController
...
@@ -3,6 +3,7 @@ class PartyListsController < ApplicationController
def
index
def
index
@party_lists
=
PartyList
.
all
@party_lists
=
PartyList
.
all
@candidates
=
Candidate
.
all
@candidates
=
Candidate
.
all
@positions
=
Position
.
all
render
"party_lists/index.html.erb"
render
"party_lists/index.html.erb"
end
end
end
end
\ No newline at end of file
Election/app/controllers/votes_controller.rb
View file @
0c21c196
...
@@ -2,37 +2,26 @@ class VotesController < ApplicationController
...
@@ -2,37 +2,26 @@ class VotesController < ApplicationController
before_action
:authenticate_user!
before_action
:authenticate_user!
def
index
def
index
@candidates_by_position
=
Candidate
.
all
.
group_by
(
&
:position_id
)
@candidates_by_position
=
Candidate
.
all
.
group_by
(
&
:position_id
)
@votes
=
Vote
.
all
end
end
def
new
def
new
if
Vote
.
exists?
(
user:
current_user
)
if
Vote
.
exists?
(
user:
current_user
)
redirect_to
root_path
,
alert:
"You have already voted."
redirect_to
root_path
,
alert:
"You have already voted."
else
else
@user
=
current_user
.
votes
.
build
@user
=
current_user
@
vote
=
Vote
.
new
@
user
.
votes
.
build
@positions
=
Position
.
all
@positions
=
Position
.
all
end
end
end
end
def
create
@candidate
=
Candidate
.
find
(
vote_params
[
:candidate_id
])
@vote
=
Vote
.
new
(
vote_params
)
@vote
.
user
=
current_user
if
@vote
.
save
redirect_to
root_path
else
render
:action
=>
'new'
end
end
def
checkout
def
checkout
if
current_user
.
update
(
vote_params
)
if
current_user
.
update
(
vote_params
()
)
redirect_to
root_path
redirect_to
root_path
else
else
@user
=
current_user
@user
=
current_user
@positions
=
Position
.
all
@positions
=
Position
.
all
redirect_to
vote_path
,
alert:
"Please accomplish all required fields."
redirect_to
vote
s_new
_path
,
alert:
"Please accomplish all required fields."
end
end
end
end
...
...
Election/app/models/candidate.rb
View file @
0c21c196
...
@@ -2,6 +2,8 @@ class Candidate < ActiveRecord::Base
...
@@ -2,6 +2,8 @@ class Candidate < ActiveRecord::Base
validates
:first_name
,
presence:
true
validates
:first_name
,
presence:
true
validates
:last_name
,
presence:
true
validates
:last_name
,
presence:
true
validates
:slogan
,
uniqueness:
true
,
presence:
true
validates
:slogan
,
uniqueness:
true
,
presence:
true
validates
:party_list
,
presence:
true
validates
:position
,
presence:
true
belongs_to
:position
belongs_to
:position
belongs_to
:party_list
belongs_to
:party_list
has_many
:votes
has_many
:votes
...
...
Election/app/models/party_list.rb
View file @
0c21c196
class
PartyList
<
ActiveRecord
::
Base
class
PartyList
<
ActiveRecord
::
Base
has_many
:candidates
has_many
:candidates
validates
:name
,
presence:
true
,
uniqueness:
true
validates
:name
,
presence:
true
,
uniqueness:
true
validates
:description
,
presence:
true
end
end
Election/app/models/user.rb
View file @
0c21c196
...
@@ -4,4 +4,5 @@ class User < ActiveRecord::Base
...
@@ -4,4 +4,5 @@ class User < ActiveRecord::Base
devise
:database_authenticatable
,
:registerable
,
devise
:database_authenticatable
,
:registerable
,
:recoverable
,
:rememberable
,
:trackable
,
:validatable
:recoverable
,
:rememberable
,
:trackable
,
:validatable
has_many
:votes
has_many
:votes
accepts_nested_attributes_for
:votes
end
end
Election/app/models/vote.rb
View file @
0c21c196
Election/app/views/admin/candidates/_form.html.erb
View file @
0c21c196
...
@@ -2,8 +2,8 @@
...
@@ -2,8 +2,8 @@
<%=
f
.
input
:first_name
%>
<%=
f
.
input
:first_name
%>
<%=
f
.
input
:last_name
%>
<%=
f
.
input
:last_name
%>
<%=
f
.
input
:nickname
%>
<%=
f
.
input
:nickname
%>
<%=
f
.
association
:party_list
,
include_blank:
fals
e
%>
<%=
f
.
association
:party_list
,
as: :select
,
include_blank:
true
,
required:
tru
e
%>
<%=
f
.
association
:position
,
include_blank:
fals
e
%>
<%=
f
.
association
:position
,
as: :select
,
include_blank:
true
,
required:
tru
e
%>
<%=
f
.
input
:slogan
%>
<%=
f
.
input
:slogan
%>
<%=
f
.
submit
%>
<%=
f
.
submit
%>
<%
end
%>
<%
end
%>
\ No newline at end of file
Election/app/views/admin/candidates/index.html.erb
View file @
0c21c196
<h1>
Admin Candidates
</h1>
<h1>
Admin Candidates
</h1>
<hr>
<hr>
<
%=
link_to
(
"New Candidate"
,
new_admin_candidate_path
)
%
>
<
button
type=
"button"
class=
"btn btn-default"
>
<%=
link_to
(
"New Candidate"
,
new_admin_candidate_path
)
%>
</button
>
<hr>
<hr>
<%
@positions
.
each
do
|
p
|
%>
<%
@positions
.
each
do
|
p
|
%>
<h2>
<%=
p
.
name
%>
</h2>
<h2>
<%=
p
.
name
%>
</h2>
<ul>
<%
p
.
candidates
.
each
do
|
candidate
|
%>
<ul>
<%
p
.
candidates
.
each
do
|
candidate
|
%>
<li>
<h5>
<%=
candidate
.
first_name
%>
<%=
candidate
.
last_name
%>
Name:
<%=
candidate
.
first_name
%>
<%=
candidate
.
last_name
%>
| Actions:
<%=
link_to
"Show"
,
admin_candidate_path
(
candidate
.
id
)
%>
<%=
link_to
"Edit"
,
edit_admin_candidate_path
(
candidate
.
id
)
%>
<%=
link_to
"Delete"
,
admin_candidate_path
(
candidate
.
id
),
method: :delete
,
data:
{
confirm:
'Are you sure?'
}
%>
<%=
link_to
"Show"
,
admin_candidate_path
(
candidate
.
id
)
%>
</h5>
<%=
link_to
"Edit"
,
edit_admin_candidate_path
(
candidate
.
id
)
%>
<%=
link_to
"Delete"
,
admin_candidate_path
(
candidate
.
id
),
method: :delete
,
data:
{
confirm:
'Are you sure?'
}
%>
</li>
<%
end
%>
<%
end
%>
</ul>
</ul>
<%
end
%>
<%
end
%>
...
...
Election/app/views/admin/candidates/show.html.erb
View file @
0c21c196
...
@@ -7,17 +7,3 @@
...
@@ -7,17 +7,3 @@
<li>
Female Voters:
<%=
@votes_female
.
size
%>
</li>
<li>
Female Voters:
<%=
@votes_female
.
size
%>
</li>
</ul>
</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/admin/party_lists/index.html.erb
View file @
0c21c196
<h1>
Admin Party Lists
</h1>
<h1>
Admin Party Lists
</h1>
<hr>
<hr>
<
%=
link_to
(
"New Party List"
,
new_admin_party_list_path
)
%
>
<
button
type=
"button"
class=
"btn btn-default"
>
<%=
link_to
(
"New Party List"
,
new_admin_party_list_path
)
%>
</button
>
<hr>
<hr>
<table
width=
"100%"
,
class=
"table table-hover"
>
<tr>
<th>
Name
</th>
</tr>
<%
@party_lists
.
each
do
|
p
|
%>
<%
@party_lists
.
each
do
|
p
|
%>
<tr>
<h3>
<%=
p
.
name
%>
<h3>
<td>
<%=
p
.
name
%>
</td>
<ul><h4>
Candidates
</h4></ul>
<td>
<%=
link_to
"Show"
,
admin_party_list_path
(
p
.
id
)
%>
<%=
link_to
"Edit"
,
edit_admin_party_list_path
(
p
.
id
)
%>
<%=
link_to
"Delete"
,
admin_party_list_path
(
p
.
id
),
method: :delete
,
data:
{
confirm:
'Are you sure?'
}
%>
</td>
</tr>
</table>
<ul>
<%
p
.
candidates
.
each
do
|
candidate
|
%>
<ul>
<%
p
.
candidates
.
each
do
|
candidate
|
%>
<li>
<h5>
<%=
candidate
.
first_name
%>
<%=
candidate
.
last_name
%>
</h5>
<%=
candidate
.
first_name
%>
<%=
candidate
.
last_name
%>
</li>
<%
end
%>
<%
end
%>
</ul>
</ul>
<h5>
Actions:
<%=
link_to
"Show"
,
admin_party_list_path
(
p
.
id
)
%>
<%=
link_to
"Edit"
,
edit_admin_party_list_path
(
p
.
id
)
%>
<%=
link_to
"Delete"
,
admin_party_list_path
(
p
.
id
),
method: :delete
,
data:
{
confirm:
'Are you sure?'
}
%>
</h5>
<hr>
<%
end
%>
<%
end
%>
<hr>
Election/app/views/admin/party_lists/show.html.erb
View file @
0c21c196
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
<h3>
Party List Description
</h3>
<h3>
Party List Description
</h3>
<%=
@party_list
.
description
%>
<%=
@party_list
.
description
%>
<%
@party_list
.
candidates
.
each
do
|
candidate
|
%>
<%
@party_list
.
candidates
.
each
do
|
candidate
|
%>
<ul>
<%=
candidate
.
first_name
%>
<%=
candidate
.
last_name
%
>
<ul>
Name:
<%=
candidate
.
first_name
%>
<%=
candidate
.
last_name
%>
</ul
>
<%
end
%>
<%
end
%>
<hr>
<hr>
<%=
link_to
"Back to Party Lists"
,
admin_party_lists_path
%>
<%=
link_to
"Back to Party Lists"
,
admin_party_lists_path
%>
\ No newline at end of file
Election/app/views/admin/positions/index.html.erb
View file @
0c21c196
<h1>
Admin Positions
</h1>
<h1>
Admin Positions
</h1>
<hr>
<hr>
<
%=
link_to
(
"New Position"
,
new_admin_position_path
)
%
>
<
button
type=
"button"
class=
"btn btn-default"
>
<%=
link_to
(
"New Position"
,
new_admin_position_path
)
%>
</button
>
<hr>
<hr>
<table
width=
"100%"
,
class=
"table table-hover"
>
<table
width=
"100%"
,
class=
"table table-hover"
>
<tr>
<tr>
...
...
Election/app/views/candidates/index.html.erb
View file @
0c21c196
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
<table
class=
"table table-hover"
,
width=
"100%"
>
<table
class=
"table table-hover"
,
width=
"100%"
>
<tr>
<tr>
<th>
Full Name
</th>
<th>
Full Name
</th>
<th>
Actions
</th>
</tr>
</tr>
<%
p
.
candidates
.
each
do
|
candidate
|
%>
<%
p
.
candidates
.
each
do
|
candidate
|
%>
<tr>
<tr>
...
...
Election/app/views/candidates/show.html.erb
View file @
0c21c196
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
<li>
User - Comment
</li>
<li>
User - Comment
</li>
<%
@votes
.
each
do
|
v
|
%>
<%
@votes
.
each
do
|
v
|
%>
<li>
<li>
<%=
v
.
user
.
email
%>
-
<%=
v
.
comment
%>
<%=
v
.
user
.
email
%>
-
<%=
v
.
comment
s
%>
</li>
</li>
<%
end
%>
<%
end
%>
</ul>
</ul>
...
...
Election/app/views/pages/index.html.erb
View file @
0c21c196
...
@@ -7,10 +7,11 @@
...
@@ -7,10 +7,11 @@
<button
type=
"button"
class=
"btn btn-default"
>
<%=
link_to
"Manage Party Lists"
,
admin_party_lists_path
%>
</button>
<button
type=
"button"
class=
"btn btn-default"
>
<%=
link_to
"Manage Party Lists"
,
admin_party_lists_path
%>
</button>
<button
type=
"button"
class=
"btn btn-default"
>
<%=
link_to
"Vote"
,
votes_new_path
%>
</button>
<button
type=
"button"
class=
"btn btn-default"
>
<%=
link_to
"Vote"
,
votes_new_path
%>
</button>
<button
type=
"button"
class=
"btn btn-default"
>
<%=
link_to
"About"
,
pages_about_path
%>
</button>
<button
type=
"button"
class=
"btn btn-default"
>
<%=
link_to
"About"
,
pages_about_path
%>
</button>
<%=
link_to
"User Profile"
,
votes_user_profile_path
%>
</button>
<
button
type=
"button"
class=
"btn btn-default"
>
<
%=
link_to
"User Profile"
,
votes_user_profile_path
%>
</button>
<%
else
%>
<%
else
%>
<button
type=
"button"
class=
"btn btn-default"
>
<%=
link_to
"About"
,
pages_about_path
%>
</button>
<button
type=
"button"
class=
"btn btn-default"
>
<%=
link_to
"About"
,
pages_about_path
%>
</button>
<button
type=
"button"
class=
"btn btn-default"
>
<%=
link_to
"Vote"
,
votes_new_path
%>
</button>
<button
type=
"button"
class=
"btn btn-default"
>
<%=
link_to
"Vote"
,
votes_new_path
%>
</button>
<button
type=
"button"
class=
"btn btn-default"
>
<%=
link_to
"Vote Record"
,
votes_index_path
%>
</button>
<button
type=
"button"
class=
"btn btn-default"
>
<%=
link_to
"User Profile"
,
votes_user_profile_path
%>
</button>
<button
type=
"button"
class=
"btn btn-default"
>
<%=
link_to
"User Profile"
,
votes_user_profile_path
%>
</button>
<%
end
%>
<%
end
%>
<hr>
<hr>
...
...
Election/app/views/party_lists/index.html.erb
View file @
0c21c196
<h1>
Party Lists
</h1>
<h1>
Party Lists
</h1>
<%
@party_lists
.
each
do
|
p
|
%>
<%
@party_lists
.
each
do
|
p
|
%>
<%=
p
.
name
%>
<h3>
<%=
p
.
name
%>
</h3>
<hr>
<h3>
Party List Description
</h3>
<h4>
Party List Description
</h4>
<%=
p
.
description
%>
<%=
p
.
description
%>
<h
3>
Party List Candidates
</h3
>
<h
4>
Party List Candidates
</h4
>
<%
p
.
candidates
.
each
do
|
candidate
|
%>
<%
p
.
candidates
.
each
do
|
candidate
|
%>
<%=
candidate
.
first_name
%>
<%=
candidate
.
last_name
%>
<%=
candidate
.
first_name
%>
<%=
candidate
.
last_name
%>
<%
end
%>
<%
end
%>
<hr>
<%
end
%>
<%
end
%>
<hr>
<hr>
<%=
link_to
"Back to Homepage"
,
root_path
%>
<%=
link_to
"Back to Homepage"
,
root_path
%>
\ No newline at end of file
Election/app/views/votes/_form.html.erb
View file @
0c21c196
<h1>
Vote for your candidates.
</h1>
<h1>
Vote for your candidates.
</h1>
<%=
simple_form_for
@vote
do
|
v
|
%>
<%=
simple_form_for
(
@user
,
url:
checkout_path
,
method: :post
)
do
|
v
|
%>
<%
@positions
.
each
do
|
p
|
%>
<%=
v
.
simple_fields_for
:votes
do
|
f
|
%>
<h2>
<%=
p
.
name
%>
</h2>
<div
class=
"row"
>
<div
class=
"col-md-6"
>
<%=
f
.
association
:candidate
,
:collection
=>
Candidate
.
where
(
position_id:
(
p
.
id
)),
include_blank:
false
,
:label_method
=>
lambda
{
|
candidate
|
"
#{
candidate
.
last_name
}
,
#{
candidate
.
first_name
}
"
},
as: :radio_buttons
,
label:
"Candidates: "
%>
<%
Candidate
.
where
(
position_id:
(
p
.
id
)).
each
do
|
candidate
|
%>
<p><div
class=
"btn btn-primary btn-xs"
data-toggle=
"popover"
data-content=
"
<%=
candidate
.
slogan
%>
"
style=
"margin-top: 2px; margin-bottom: 1px"
,
data-trigger=
"focus"
,
role=
"button"
,
tabindex=
"0"
,
title=
"
<%=
candidate
.
first_name
%>
<%=
candidate
.
last_name
%>
"
>
View
<%=
candidate
.
last_name
%>
's Slogan
</div></p>
<%
end
-%>
</div>
<div
class=
"col-md-6"
>
<%=
v
.
association
:candidate
,
include_blank:
false
,
collection:
@candidates
%>
<br><br><br>
</div>
</div>
<%=
f
.
input
:comments
%>
<%
end
-%>
<%
end
-%>
<%=
v
.
input
:comments
%>
<br>
<%=
v
.
button
:submit
,
"Submit"
%>
<%=
v
.
button
:submit
,
"Vote"
,
class:
"btn btn-primary"
%>
<%=
link_to
"Back to Homepage"
,
root_path
,
class:
"btn btn-default"
%>
<%=
link_to
"Vote Record"
,
votes_index_path
,
class:
"btn btn-default"
%>
<%
end
%>
<%
end
%>
<script>
$
(
document
).
ready
(
function
(){
$
(
'[data-toggle="popover"]'
).
popover
();
});
</script>
\ No newline at end of file
Election/app/views/votes/index.html.erb
View file @
0c21c196
<h1>
Votes
</h1>
<h1>
Votes
</h1>
<%=
link_to
"Vote Now!"
,
new_vote
_path
%>
<%=
link_to
"Vote Now!"
,
votes_new
_path
%>
<table
width=
"100%"
>
<table
width=
"100%"
>
<tr>
<tr>
<th>
#
</th>
<th>
#
</th>
<th>
User ID
</th>
<th>
User ID
</th>
<th>
Candidate
</th>
<th>
Candidate
</th>
<th>
Position
</th>
<th>
Position
</th>
<th>
Comments
</th>
</tr>
</tr>
<%
@votes
.
each
do
|
vote
|
%>
<%
@votes
.
each
do
|
vote
|
%>
...
@@ -18,6 +19,7 @@
...
@@ -18,6 +19,7 @@
<td>
<td>
<%=
vote
.
candidate
.
position
.
name
%>
<%=
vote
.
candidate
.
position
.
name
%>
</td>
</td>
<td>
<%=
vote
.
comments
%>
</td>
</tr>
</tr>
<%
end
%>
<%
end
%>
</table>
</table>
\ No newline at end of file
Election/app/views/votes/show.html.erb
deleted
100644 → 0
View file @
4d236ef5
<h1>
Vote Record
</h1>
<table
class=
"table"
>
<thead>
<th>
Candidate
</th>
<th>
Position
</th>
<th>
Comments
</th>
</thead>
<tbody>
<%
if
!
@votes
.
empty?
%>
<%
@positions
.
each
do
|
positions
|
%>
<%
current_user
.
votes
.
each
do
|
blah
|
%>
<%
@candidates
.
each
do
|
candidates
|
%>
<%
if
candidates
.
position
.
name
==
positions
.
name
%>
<tr>
<td>
<%=
candidates
.
first_name
%>
<%=
candidates
.
last_name
%>
</td>
<td>
<%=
candidates
.
position
.
name
%>
</td>
<td>
<%=
blah
.
comments
%>
</td>
</tr>
<%
end
%>
<%
end
%>
<%
end
%>
<%
end
%>
<%
else
%>
<tr>
<td
colspan=
"3"
><em>
No Votes Found
</em></td>
</tr>
<%
end
%>
</tbody>
</table>
<hr>
<%=
link_to
"Vote"
,
votes_path
%>
<%=
link_to
"Back to Homepage"
,
root_path
%>
\ No newline at end of file
Election/app/views/votes/user_profile.html.erb
View file @
0c21c196
<h1>
Profile Page
</h1>
<h1>
Profile Page
</h1>
<h2>
<%=
current_user
.
id
%>
<%=
current_user
.
first_name
%>
<%=
current_user
.
last_name
%>
</h2>
<h2>
<%=
current_user
.
first_name
%>
<%=
current_user
.
last_name
%>
</h2>
<hr>
<hr>
<h2>
Positions
</h2>
<h2>
Candidates Voted For
</h2>
<%
@positions
.
each
do
|
p
|
%>
<%
@positions
.
each
do
|
p
|
%>
<h3>
<%=
p
.
name
%>
</h3>
<h3>
<%=
p
.
name
%>
</h3>
<%
p
.
candidates
.
each
do
|
c
|
%>
<%
p
.
candidates
.
each
do
|
c
|
%>
<%
c
.
votes
.
each
do
|
v
|
%>
<%
c
.
votes
.
each
do
|
v
|
%>
<%
if
v
.
user_id
==
current_user
.
id
%>
<%
if
v
.
user_id
==
current_user
.
id
%>
<%=
v
.
candidate
.
first_name
%>
<%=
v
.
candidate
.
last_name
%>
<%=
v
.
comments
%>
Name:
<%=
v
.
candidate
.
first_name
%>
<%=
v
.
candidate
.
last_name
%>
|| Comments:
<%=
v
.
comments
%>
<%
else
%>
<%
else
%>
<%
end
%>
<%
end
%>
<%
end
%>
<%
end
%>
...
...
Election/config/routes.rb
View file @
0c21c196
...
@@ -16,7 +16,6 @@ Rails.application.routes.draw do
...
@@ -16,7 +16,6 @@ Rails.application.routes.draw do
get
'/party_lists/index'
,
to:
"party_lists#index"
get
'/party_lists/index'
,
to:
"party_lists#index"
get
'/votes/user_profile'
,
to:
"votes#profile"
get
'/votes/user_profile'
,
to:
"votes#profile"
get
'/votes/index'
,
to:
"votes#index"
get
'/votes/index'
,
to:
"votes#index"
get
'/election/vote/:id'
,
to:
"election#vote"
post
'/checkout'
,
to:
'votes#checkout'
,
as: :checkout
post
'/checkout'
,
to:
'votes#checkout'
,
as: :checkout
end
end
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