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
6c976fe2
Commit
6c976fe2
authored
Jul 22, 2016
by
Bianca Tarun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed admin views and added seeds
parent
b748ee06
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
126 additions
and
17 deletions
+126
-17
election_controller.rb
Election/app/controllers/election_controller.rb
+9
-0
vote.rb
Election/app/models/vote.rb
+1
-0
_form.html.erb
Election/app/views/admin/candidates/_form.html.erb
+4
-0
edit.html.erb
Election/app/views/admin/candidates/edit.html.erb
+4
-0
index.html.erb
Election/app/views/admin/candidates/index.html.erb
+4
-1
new.html.erb
Election/app/views/admin/candidates/new.html.erb
+4
-0
show.html.erb
Election/app/views/admin/candidates/show.html.erb
+4
-1
_form.html.erb
Election/app/views/admin/party_lists/_form.html.erb
+4
-0
edit.html.erb
Election/app/views/admin/party_lists/edit.html.erb
+5
-1
index.html.erb
Election/app/views/admin/party_lists/index.html.erb
+6
-2
new.html.erb
Election/app/views/admin/party_lists/new.html.erb
+5
-1
show.html.erb
Election/app/views/admin/party_lists/show.html.erb
+5
-1
_form.html.erb
Election/app/views/admin/positions/_form.html.erb
+4
-0
edit.html.erb
Election/app/views/admin/positions/edit.html.erb
+5
-1
index.html.erb
Election/app/views/admin/positions/index.html.erb
+4
-0
new.html.erb
Election/app/views/admin/positions/new.html.erb
+4
-0
show.html.erb
Election/app/views/admin/positions/show.html.erb
+5
-1
application.html.erb
Election/app/views/layouts/application.html.erb
+1
-0
index.html.erb
Election/app/views/pages/index.html.erb
+1
-4
index.html.erb
Election/app/views/votes/index.html.erb
+4
-4
show.html.erb
Election/app/views/votes/show.html.erb
+32
-0
seeds.rb
Election/db/seeds.rb
+11
-0
No files found.
Election/app/controllers/election_controller.rb
0 → 100644
View file @
6c976fe2
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/models/vote.rb
View file @
6c976fe2
...
@@ -2,6 +2,7 @@ class Vote < ActiveRecord::Base
...
@@ -2,6 +2,7 @@ class Vote < ActiveRecord::Base
belongs_to
:user
belongs_to
:user
belongs_to
:candidate
belongs_to
:candidate
validates
:candidate_id
,
presence:
true
validates
:candidate_id
,
presence:
true
validates
:comments
,
presence:
true
def
to_s
def
to_s
"
#{
candidate
.
first_name
}
#{
candidate
.
last_name
}
"
"
#{
candidate
.
first_name
}
#{
candidate
.
last_name
}
"
end
end
...
...
Election/app/views/admin/candidates/_form.html.erb
View file @
6c976fe2
<%
if
current_user
.
email
==
"admin_email@yahoo.com"
%>
<%=
simple_form_for
([
:admin
,
@candidate
])
do
|
f
|
%>
<%=
simple_form_for
([
:admin
,
@candidate
])
do
|
f
|
%>
<%=
f
.
input
:first_name
%>
<%=
f
.
input
:first_name
%>
<%=
f
.
input
:last_name
%>
<%=
f
.
input
:last_name
%>
...
@@ -6,4 +7,7 @@
...
@@ -6,4 +7,7 @@
<%=
f
.
association
:position
,
as: :select
,
include_blank:
true
,
required:
true
%>
<%=
f
.
association
:position
,
as: :select
,
include_blank:
true
,
required:
true
%>
<%=
f
.
input
:slogan
%>
<%=
f
.
input
:slogan
%>
<%=
f
.
submit
%>
<%=
f
.
submit
%>
<%
end
%>
<%
else
%>
<h1>
<%=
"You do not have acces to this feature"
%>
</h1>
<%
end
%>
<%
end
%>
\ No newline at end of file
Election/app/views/admin/candidates/edit.html.erb
View file @
6c976fe2
<%
if
current_user
.
email
==
"admin_email@yahoo.com"
%>
<h1>
Admin Edit Candidate
</h1>
<h1>
Admin Edit Candidate
</h1>
<%=
render
partial:
"form"
%>
<%=
render
partial:
"form"
%>
<%=
link_to
"Back to Candidates"
,
admin_candidates_path
%>
<%=
link_to
"Back to Candidates"
,
admin_candidates_path
%>
<
<%
else
%>
<
h1
>
<%=
"You do not have acces to this feature"
%>
</h1>
<%
end
%>
\ No newline at end of file
Election/app/views/admin/candidates/index.html.erb
View file @
6c976fe2
<%
if
current_user
.
email
==
"admin_email@yahoo.com"
%>
<h1>
Admin Candidates
</h1>
<h1>
Admin Candidates
</h1>
<hr>
<hr>
<button
type=
"button"
class=
"btn btn-default"
>
<%=
link_to
(
"New Candidate"
,
new_admin_candidate_path
)
%>
</button>
<button
type=
"button"
class=
"btn btn-default"
>
<%=
link_to
(
"New Candidate"
,
new_admin_candidate_path
)
%>
</button>
...
@@ -11,5 +12,7 @@
...
@@ -11,5 +12,7 @@
<%
end
%>
<%
end
%>
</ul>
</ul>
<%
end
%>
<%
end
%>
<%
else
%>
<h1>
<%=
"You do not have acces to this feature"
%>
</h1>
<%
end
%>
Election/app/views/admin/candidates/new.html.erb
View file @
6c976fe2
<%
if
current_user
.
email
==
"admin_email@yahoo.com"
%>
<h1>
Admin New Candidate
</h1>
<h1>
Admin New Candidate
</h1>
<%=
render
partial:
"form"
%>
<%=
render
partial:
"form"
%>
<%=
link_to
"Back to Candidates"
,
admin_candidates_path
%>
<%=
link_to
"Back to Candidates"
,
admin_candidates_path
%>
<%
else
%>
<h1>
<%=
"You do not have acces to this feature"
%>
</h1>
<%
end
%>
\ No newline at end of file
Election/app/views/admin/candidates/show.html.erb
View file @
6c976fe2
<%
if
current_user
.
email
==
"admin_email@yahoo.com"
%>
<h2>
Candidate:
<%=
@candidate
.
first_name
%>
<%=
@candidate
.
last_name
%>
</h2>
<h2>
Candidate:
<%=
@candidate
.
first_name
%>
<%=
@candidate
.
last_name
%>
</h2>
<h4>
Party List:
<%=
@candidate
.
party_list
.
name
%>
</h4>
<h4>
Party List:
<%=
@candidate
.
party_list
.
name
%>
</h4>
<h3>
<%=
@candidate
.
last_name
%>
's Slogan:
<%=
@candidate
.
slogan
%>
</h3>
<h3>
<%=
@candidate
.
last_name
%>
's Slogan:
<%=
@candidate
.
slogan
%>
</h3>
...
@@ -6,4 +7,6 @@
...
@@ -6,4 +7,6 @@
<li>
Male Voters:
<%=
@votes_male
.
size
%>
(
<%=
@votes_male
.
size
*
100
/
@votes
.
size
%>
%)
</li>
<li>
Male Voters:
<%=
@votes_male
.
size
%>
(
<%=
@votes_male
.
size
*
100
/
@votes
.
size
%>
%)
</li>
<li>
Female Voters:
<%=
@votes_female
.
size
%>
(
<%=
@votes_female
.
size
*
100
/
@votes
.
size
%>
%)
</li>
<li>
Female Voters:
<%=
@votes_female
.
size
%>
(
<%=
@votes_female
.
size
*
100
/
@votes
.
size
%>
%)
</li>
</ul>
</ul>
<%
else
%>
<h1>
<%=
"You do not have acces to this feature"
%>
</h1>
<%
end
%>
\ No newline at end of file
Election/app/views/admin/party_lists/_form.html.erb
View file @
6c976fe2
<%
if
current_user
.
email
==
"admin_email@yahoo.com"
%>
<%=
simple_form_for
([
:admin
,
@party_list
])
do
|
f
|
%>
<%=
simple_form_for
([
:admin
,
@party_list
])
do
|
f
|
%>
<%=
f
.
input
:name
%>
<%=
f
.
input
:name
%>
<%=
f
.
input
:description
%>
<%=
f
.
input
:description
%>
<%=
f
.
submit
%>
<%=
f
.
submit
%>
<%
end
%>
<%
else
%>
<h1>
<%=
"You do not have acces to this feature"
%>
</h1>
<%
end
%>
<%
end
%>
\ No newline at end of file
Election/app/views/admin/party_lists/edit.html.erb
View file @
6c976fe2
<%
if
current_user
.
email
==
"admin_email@yahoo.com"
%>
<h1>
Admin Edit Party List
</h1>
<h1>
Admin Edit Party List
</h1>
<%=
render
partial:
"form"
%>
<%=
render
partial:
"form"
%>
<%=
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
<%
else
%>
<h1>
<%=
"You do not have acces to this feature"
%>
</h1>
<%
end
%>
\ No newline at end of file
Election/app/views/admin/party_lists/index.html.erb
View file @
6c976fe2
<%
if
current_user
.
email
==
"admin_email@yahoo.com"
%>
<h1>
Admin Party Lists
</h1>
<h1>
Admin Party Lists
</h1>
<hr>
<hr>
<button
type=
"button"
class=
"btn btn-default"
>
<%=
link_to
(
"New Party List"
,
new_admin_party_list_path
)
%>
</button>
<button
type=
"button"
class=
"btn btn-default"
>
<%=
link_to
(
"New Party List"
,
new_admin_party_list_path
)
%>
</button>
...
@@ -7,7 +8,7 @@
...
@@ -7,7 +8,7 @@
<ul><h4>
Candidates
</h4></ul>
<ul><h4>
Candidates
</h4></ul>
<ul>
<%
p
.
candidates
.
each
do
|
candidate
|
%>
<ul>
<%
p
.
candidates
.
each
do
|
candidate
|
%>
<h5>
<%=
candidate
.
first_name
%>
<%=
candidate
.
last_name
%>
-
<%=
candidate
.
position
.
name
%>
</h5>
<h5>
<%=
candidate
.
first_name
%>
<%=
candidate
.
last_name
%>
-
<%=
candidate
.
position
.
name
%>
</h5>
<%
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>
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?'
}
%>
...
@@ -15,4 +16,7 @@
...
@@ -15,4 +16,7 @@
<hr>
<hr>
<%
end
%>
<%
end
%>
<hr>
<hr>
<%
else
%>
<%
else
%>
<h1>
<%=
"You do not have acces to this feature"
%>
</h1>
<%
end
%>
Election/app/views/admin/party_lists/new.html.erb
View file @
6c976fe2
<%
if
current_user
.
email
==
"admin_email@yahoo.com"
%>
<h1>
Admin New Party List
</h1>
<h1>
Admin New Party List
</h1>
<%=
render
partial:
"form"
%>
<%=
render
partial:
"form"
%>
<%=
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
<%
else
%>
<h1>
<%=
"You do not have acces to this feature"
%>
</h1>
<%
end
%>
\ No newline at end of file
Election/app/views/admin/party_lists/show.html.erb
View file @
6c976fe2
<%
if
current_user
.
email
==
"admin_email@yahoo.com"
%>
<h1>
Party List:
<%=
@party_list
.
name
%>
</h1>
<h1>
Party List:
<%=
@party_list
.
name
%>
</h1>
<hr>
<hr>
<h3>
Party List Description
</h3>
<h3>
Party List Description
</h3>
...
@@ -6,4 +7,7 @@
...
@@ -6,4 +7,7 @@
<ul>
Name:
<%=
candidate
.
first_name
%>
<%=
candidate
.
last_name
%>
</ul>
<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
<%
else
%>
<h1>
<%=
"You do not have acces to this feature"
%>
</h1>
<%
end
%>
\ No newline at end of file
Election/app/views/admin/positions/_form.html.erb
View file @
6c976fe2
<%
if
current_user
.
email
==
"admin_email@yahoo.com"
%>
<%=
simple_form_for
([
:admin
,
@position
])
do
|
f
|
%>
<%=
simple_form_for
([
:admin
,
@position
])
do
|
f
|
%>
<%=
f
.
input
:name
%>
<%=
f
.
input
:name
%>
<%=
f
.
submit
%>
<%=
f
.
submit
%>
<%
end
%>
<%
else
%>
<h1>
<%=
"You do not have acces to this feature"
%>
</h1>
<%
end
%>
<%
end
%>
\ No newline at end of file
Election/app/views/admin/positions/edit.html.erb
View file @
6c976fe2
<%
if
current_user
.
email
==
"admin_email@yahoo.com"
%>
<h1>
Admin Edit Position
</h1>
<h1>
Admin Edit Position
</h1>
<%=
render
partial:
"form"
%>
<%=
render
partial:
"form"
%>
<%=
link_to
"Back to Position"
,
admin_positions_path
%>
<%=
link_to
"Back to Position"
,
admin_positions_path
%>
\ No newline at end of file
<%
else
%>
<h1>
<%=
"You do not have acces to this feature"
%>
</h1>
<%
end
%>
\ No newline at end of file
Election/app/views/admin/positions/index.html.erb
View file @
6c976fe2
<%
if
current_user
.
email
==
"admin_email@yahoo.com"
%>
<h1>
Admin Positions
</h1>
<h1>
Admin Positions
</h1>
<hr>
<hr>
<button
type=
"button"
class=
"btn btn-default"
>
<%=
link_to
(
"New Position"
,
new_admin_position_path
)
%>
</button>
<button
type=
"button"
class=
"btn btn-default"
>
<%=
link_to
(
"New Position"
,
new_admin_position_path
)
%>
</button>
...
@@ -18,3 +19,6 @@
...
@@ -18,3 +19,6 @@
<%
end
%>
<%
end
%>
</table>
</table>
<hr>
<hr>
<%
else
%>
<h1>
<%=
"You do not have acces to this feature"
%>
</h1>
<%
end
%>
\ No newline at end of file
Election/app/views/admin/positions/new.html.erb
View file @
6c976fe2
<%
if
current_user
.
email
==
"admin_email@yahoo.com"
%>
<h1>
Admin New Position
</h1>
<h1>
Admin New Position
</h1>
<%=
render
partial:
"form"
%>
<%=
render
partial:
"form"
%>
<%=
link_to
"Back to Position"
,
admin_positions_path
%>
<%=
link_to
"Back to Position"
,
admin_positions_path
%>
<%
else
%>
<h1>
<%=
"You do not have acces to this feature"
%>
</h1>
<%
end
%>
\ No newline at end of file
Election/app/views/admin/positions/show.html.erb
View file @
6c976fe2
<%
if
current_user
.
email
==
"admin_email@yahoo.com"
%>
<h1>
Position:
<%=
@position
.
name
%>
</h1>
<h1>
Position:
<%=
@position
.
name
%>
</h1>
<h2>
Candidates:
</h2>
<h2>
Candidates:
</h2>
<ul>
<ul>
...
@@ -5,4 +6,7 @@
...
@@ -5,4 +6,7 @@
<li>
<%=
link_to
"
#{
c
.
first_name
}
"
+
"
#{
c
.
last_name
}
"
,
admin_candidate_path
(
c
.
id
)
%>
</li>
<li>
<%=
link_to
"
#{
c
.
first_name
}
"
+
"
#{
c
.
last_name
}
"
,
admin_candidate_path
(
c
.
id
)
%>
</li>
<%
end
%>
<%
end
%>
</ul>
</ul>
<%=
link_to
"Back to Positions"
,
admin_positions_path
%>
<%=
link_to
"Back to Positions"
,
admin_positions_path
%>
\ No newline at end of file
<%
else
%>
<h1>
<%=
"You do not have acces to this feature"
%>
</h1>
<%
end
%>
\ No newline at end of file
Election/app/views/layouts/application.html.erb
View file @
6c976fe2
...
@@ -20,3 +20,4 @@
...
@@ -20,3 +20,4 @@
</body>
</body>
</html>
</html>
Election/app/views/pages/index.html.erb
View file @
6c976fe2
...
@@ -22,15 +22,12 @@
...
@@ -22,15 +22,12 @@
<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>
Number of Votes
</th>
<th>
Number of Votes
</th>
</tr>
</tr>
<%
p
.
candidates
.
each
do
|
candidate
|
%>
<%
p
.
candidates
.
each
do
|
candidate
|
%>
<tr>
<tr>
<td>
<%=
link_to
"
#{
candidate
.
first_name
}
#{
candidate
.
last_name
}
"
,
candidate_path
(
candidate
.
id
)
%>
</td>
<td>
<%=
link_to
"
#{
candidate
.
first_name
}
#{
candidate
.
last_name
}
"
,
candidate_path
(
candidate
.
id
)
%>
</td>
<td>
<%=
Vote
.
where
(
candidate_id:
candidate
.
id
).
count
%>
</td>
<td>
<%=
Vote
.
where
(
candidate_id:
candidate
.
id
).
count
%>
</td>
</tr>
</tr>
<%
end
%>
<%
end
%>
</table>
</table>
...
...
Election/app/views/votes/index.html.erb
View file @
6c976fe2
<h1>
Votes
</h1>
<h1>
Votes
</h1>
<table
width=
"100%"
>
<table
width=
"100%"
>
<tr>
<tr>
<th>
Vote ID
</th>
<th>
Vote ID
</th>
<th>
Candidate
</th>
<th>
Candidate
</th>
<th>
Position
</th>
<th>
Position
</th>
<th>
Comments
</th>
<th>
Comments
</th>
</tr>
</tr>
<%
@votes
.
each
do
|
vote
|
%>
<%
@votes
.
each
do
|
vote
|
%>
<tr>
<tr>
<td>
<%=
vote
.
id
%>
</td>
<td>
<%=
vote
.
id
%>
</td>
<td>
<td>
...
...
Election/app/views/votes/show.html.erb
0 → 100644
View file @
6c976fe2
<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/db/seeds.rb
View file @
6c976fe2
...
@@ -6,3 +6,14 @@
...
@@ -6,3 +6,14 @@
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
# Mayor.create(name: 'Emanuel', city: cities.first)
User
.
create
(
first_name:
'Admin'
,
last_name:
'Admin'
,
birthday:
'1992-09-03'
,
email:
'admin_email@yahoo.com'
,
password:
'password'
,
gender:
'Male'
)
User
.
create
(
first_name:
'Admin'
,
last_name:
'Admin'
,
birthday:
'1992-09-03'
,
email:
'admin_email@yahoo.com'
,
password:
'password'
,
gender:
'Male'
)
Position
.
create
(
name:
'President'
,
id:
1
)
Position
.
create
(
name:
'Vice President'
,
id:
2
)
PartyList
.
create
(
name:
'Party List A'
,
description:
'AAA'
,
id:
1
)
PartyList
.
create
(
name:
'Party List B'
,
description:
'BBB'
,
id:
2
)
PartyList
.
create
(
name:
'Party List C'
,
description:
'CCC'
,
id:
3
)
Candidate
.
create
(
first_name:
'Cand.'
,
last_name:
'A1'
,
nickname:
'CA1'
,
position_id:
1
,
party_list_id:
1
,
slogan:
'A1 all the way!'
)
Candidate
.
create
(
first_name:
'Cand.'
,
last_name:
'A2'
,
nickname:
'CA2'
,
position_id:
2
,
party_list_id:
1
,
slogan:
'A2 all the way!'
)
Candidate
.
create
(
first_name:
'Cand.'
,
last_name:
'B1'
,
nickname:
'CB1'
,
position_id:
1
,
party_list_id:
2
,
slogan:
'B1 all the way!'
)
Candidate
.
create
(
first_name:
'Cand.'
,
last_name:
'B2'
,
nickname:
'CB2'
,
position_id:
2
,
party_list_id:
2
,
slogan:
'B2 all the way!'
)
Candidate
.
create
(
first_name:
'Cand.'
,
last_name:
'C1'
,
nickname:
'CC1'
,
position_id:
1
,
party_list_id:
3
,
slogan:
'C1 all the way!'
)
Candidate
.
create
(
first_name:
'Cand.'
,
last_name:
'C2'
,
nickname:
'CC2'
,
position_id:
2
,
party_list_id:
3
,
slogan:
'C2 all the way!'
)
\ No newline at end of file
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