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
Show 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
belongs_to
:user
belongs_to
:candidate
validates
:candidate_id
,
presence:
true
validates
:comments
,
presence:
true
def
to_s
"
#{
candidate
.
first_name
}
#{
candidate
.
last_name
}
"
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
|
%>
<%=
f
.
input
:first_name
%>
<%=
f
.
input
:last_name
%>
...
...
@@ -7,3 +8,6 @@
<%=
f
.
input
:slogan
%>
<%=
f
.
submit
%>
<%
end
%>
<%
else
%>
<h1>
<%=
"You do not have acces to this feature"
%>
</h1>
<%
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>
<%=
render
partial:
"form"
%>
<%=
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>
<hr>
<button
type=
"button"
class=
"btn btn-default"
>
<%=
link_to
(
"New Candidate"
,
new_admin_candidate_path
)
%>
</button>
...
...
@@ -11,5 +12,7 @@
<%
end
%>
</ul>
<%
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>
<%=
render
partial:
"form"
%>
<%=
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>
<h4>
Party List:
<%=
@candidate
.
party_list
.
name
%>
</h4>
<h3>
<%=
@candidate
.
last_name
%>
's Slogan:
<%=
@candidate
.
slogan
%>
</h3>
...
...
@@ -6,4 +7,6 @@
<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>
</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
|
%>
<%=
f
.
input
:name
%>
<%=
f
.
input
:description
%>
<%=
f
.
submit
%>
<%
end
%>
<%
else
%>
<h1>
<%=
"You do not have acces to this feature"
%>
</h1>
<%
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>
<%=
render
partial:
"form"
%>
<%=
link_to
"Back to Party Lists"
,
admin_party_lists_path
%>
<%
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>
<hr>
<button
type=
"button"
class=
"btn btn-default"
>
<%=
link_to
(
"New Party List"
,
new_admin_party_list_path
)
%>
</button>
...
...
@@ -15,4 +16,7 @@
<hr>
<%
end
%>
<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>
<%=
render
partial:
"form"
%>
<%=
link_to
"Back to Party Lists"
,
admin_party_lists_path
%>
<%
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>
<hr>
<h3>
Party List Description
</h3>
...
...
@@ -7,3 +8,6 @@
<%
end
%>
<hr>
<%=
link_to
"Back to Party Lists"
,
admin_party_lists_path
%>
<%
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
|
%>
<%=
f
.
input
:name
%>
<%=
f
.
submit
%>
<%
end
%>
<%
else
%>
<h1>
<%=
"You do not have acces to this feature"
%>
</h1>
<%
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>
<%=
render
partial:
"form"
%>
<%=
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/index.html.erb
View file @
6c976fe2
<%
if
current_user
.
email
==
"admin_email@yahoo.com"
%>
<h1>
Admin Positions
</h1>
<hr>
<button
type=
"button"
class=
"btn btn-default"
>
<%=
link_to
(
"New Position"
,
new_admin_position_path
)
%>
</button>
...
...
@@ -18,3 +19,6 @@
<%
end
%>
</table>
<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>
<%=
render
partial:
"form"
%>
<%=
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>
<h2>
Candidates:
</h2>
<ul>
...
...
@@ -6,3 +7,6 @@
<%
end
%>
</ul>
<%=
link_to
"Back to Positions"
,
admin_positions_path
%>
<%
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 @@
</body>
</html>
Election/app/views/pages/index.html.erb
View file @
6c976fe2
...
...
@@ -23,14 +23,11 @@
<tr>
<th>
Full Name
</th>
<th>
Number of Votes
</th>
</tr>
<%
p
.
candidates
.
each
do
|
candidate
|
%>
<tr>
<td>
<%=
link_to
"
#{
candidate
.
first_name
}
#{
candidate
.
last_name
}
"
,
candidate_path
(
candidate
.
id
)
%>
</td>
<td>
<%=
Vote
.
where
(
candidate_id:
candidate
.
id
).
count
%>
</td>
</tr>
<%
end
%>
</table>
...
...
Election/app/views/votes/index.html.erb
View file @
6c976fe2
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 @@
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# 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'
)
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