Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
finalproject
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
AngKo_Catolico_Ilicito_Reyes
finalproject
Commits
168e4c7b
Commit
168e4c7b
authored
Jul 19, 2016
by
Norence Ilicito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
voting module, incomplete
parent
94a5cd72
Changes
32
Hide whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
202 additions
and
7 deletions
+202
-7
application_controller.rb
election_2016/app/controllers/application_controller.rb
+12
-0
votes_controller.rb
election_2016/app/controllers/votes_controller.rb
+38
-0
vote.rb
election_2016/app/models/vote.rb
+2
-0
_form.html.erb
election_2016/app/views/candidates/_form.html.erb
+3
-0
edit.html.erb
election_2016/app/views/candidates/edit.html.erb
+3
-0
new.html.erb
election_2016/app/views/candidates/new.html.erb
+3
-0
show.html.erb
election_2016/app/views/candidates/show.html.erb
+2
-0
new.html.erb
election_2016/app/views/devise/confirmations/new.html.erb
+3
-0
confirmation_instructions.html.erb
...pp/views/devise/mailer/confirmation_instructions.html.erb
+3
-0
password_change.html.erb
...ion_2016/app/views/devise/mailer/password_change.html.erb
+3
-0
reset_password_instructions.html.erb
.../views/devise/mailer/reset_password_instructions.html.erb
+3
-0
unlock_instructions.html.erb
...2016/app/views/devise/mailer/unlock_instructions.html.erb
+3
-0
edit.html.erb
election_2016/app/views/devise/passwords/edit.html.erb
+3
-0
new.html.erb
election_2016/app/views/devise/passwords/new.html.erb
+3
-0
edit.html.erb
election_2016/app/views/devise/registrations/edit.html.erb
+3
-0
new.html.erb
election_2016/app/views/devise/registrations/new.html.erb
+4
-1
new.html.erb
election_2016/app/views/devise/sessions/new.html.erb
+3
-0
_links.html.erb
election_2016/app/views/devise/shared/_links.html.erb
+3
-0
new.html.erb
election_2016/app/views/devise/unlocks/new.html.erb
+3
-0
index.html.erb
election_2016/app/views/pages/index.html.erb
+3
-0
profiles.html.erb
election_2016/app/views/pages/profiles.html.erb
+11
-4
statistic.html.erb
election_2016/app/views/pages/statistic.html.erb
+0
-1
_form.html.erb
election_2016/app/views/positions/_form.html.erb
+3
-0
edit.html.erb
election_2016/app/views/positions/edit.html.erb
+3
-0
new.html.erb
election_2016/app/views/positions/new.html.erb
+3
-0
show.html.erb
election_2016/app/views/positions/show.html.erb
+3
-0
vote.html.erb
election_2016/app/views/vote/vote.html.erb
+18
-0
vote_record.erb
election_2016/app/views/vote/vote_record.erb
+20
-0
20160719105648_create_votes.rb
election_2016/db/migrate/20160719105648_create_votes.rb
+11
-0
schema.rb
election_2016/db/schema.rb
+9
-1
votes.yml
election_2016/test/fixtures/votes.yml
+11
-0
vote_test.rb
election_2016/test/models/vote_test.rb
+7
-0
No files found.
election_2016/app/controllers/application_controller.rb
View file @
168e4c7b
...
...
@@ -2,4 +2,16 @@ class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery
with: :exception
before_action
:configure_permitted_parameters
,
if: :devise_controller?
protected
def
configure_permitted_parameters
devise_parameter_sanitizer
.
permit
(
:sign_up
,
keys:
[
:email
,
:password
,
:password_confirmation
,
:first_name
,
:last_name
,
:gender
,
:birthday
])
# devise_parameter_sanitizer.permit(:sign_in, keys: [:email, :password])
devise_parameter_sanitizer
.
permit
(
:account_update
,
keys:
[
:email
,
:password
,
:password_confirmation
,
:current_password
,
:first_name
,
:last_name
,
:gender
,
:birthday
])
end
end
election_2016/app/controllers/votes_controller.rb
0 → 100644
View file @
168e4c7b
class
VotesController
<
ApplicationController
before_action
:authenticate_user!
,
except:
[
:index
]
def
index
@candidates
=
Candidate
.
all
.
group_by
(
&
:position_id
)
end
def
vote
@vote
=
Vote
.
new
@candidates
=
Candidate
.
all
.
group_by
(
&
:position_id
)
end
def
confirm_vote
@vote
=
Vote
.
new
(
vote_params
)
@vote
.
user
=
current_user
if
@vote
.
save
(
vote_params
)
if
current_user
.
votes
.
count
>=
Position
.
count
redirect_to
root_path
,
notice:
"You have already exceeded your number of votes."
else
redirect_to
:vote
,
notice:
"Vote successful!"
end
else
render
:vote
end
end
def
vote_history
@votes
=
current_user
.
votes
end
private
def
vote_params
params
.
require
(
:vote
).
permit!
end
end
election_2016/app/models/vote.rb
0 → 100644
View file @
168e4c7b
class
Vote
<
ActiveRecord
::
Base
end
election_2016/app/views/candidates/_form.html.erb
View file @
168e4c7b
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<%=
simple_form_for
(
@candidate
)
do
|
c
|
%>
<%=
c
.
input
:id
%>
<%=
c
.
input
:first_name
%>
...
...
election_2016/app/views/candidates/edit.html.erb
View file @
168e4c7b
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<h1>
Edit Candidate
</h1>
<%=
render
partial:
"form"
%>
...
...
election_2016/app/views/candidates/new.html.erb
View file @
168e4c7b
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<h1>
New Candidate
</h1>
<%=
render
partial:
"form"
%>
...
...
election_2016/app/views/candidates/show.html.erb
View file @
168e4c7b
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<h1>
<%=
@candidate
.
first_name
%>
<%=
@candidate
.
last_name
%>
...
...
election_2016/app/views/devise/confirmations/new.html.erb
View file @
168e4c7b
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<h2>
Resend confirmation instructions
</h2>
<%=
simple_form_for
(
resource
,
as:
resource_name
,
url:
confirmation_path
(
resource_name
),
html:
{
method: :post
})
do
|
f
|
%>
...
...
election_2016/app/views/devise/mailer/confirmation_instructions.html.erb
View file @
168e4c7b
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<p>
Welcome
<%=
@email
%>
!
</p>
<p>
You can confirm your account email through the link below:
</p>
...
...
election_2016/app/views/devise/mailer/password_change.html.erb
View file @
168e4c7b
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<p>
Hello
<%=
@resource
.
email
%>
!
</p>
<p>
We're contacting you to notify you that your password has been changed.
</p>
election_2016/app/views/devise/mailer/reset_password_instructions.html.erb
View file @
168e4c7b
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<p>
Hello
<%=
@resource
.
email
%>
!
</p>
<p>
Someone has requested a link to change your password. You can do this through the link below.
</p>
...
...
election_2016/app/views/devise/mailer/unlock_instructions.html.erb
View file @
168e4c7b
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<p>
Hello
<%=
@resource
.
email
%>
!
</p>
<p>
Your account has been locked due to an excessive number of unsuccessful sign in attempts.
</p>
...
...
election_2016/app/views/devise/passwords/edit.html.erb
View file @
168e4c7b
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<h2>
Change your password
</h2>
<%=
simple_form_for
(
resource
,
as:
resource_name
,
url:
password_path
(
resource_name
),
html:
{
method: :put
})
do
|
f
|
%>
...
...
election_2016/app/views/devise/passwords/new.html.erb
View file @
168e4c7b
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<h2>
Forgot your password?
</h2>
<%=
simple_form_for
(
resource
,
as:
resource_name
,
url:
password_path
(
resource_name
),
html:
{
method: :post
})
do
|
f
|
%>
...
...
election_2016/app/views/devise/registrations/edit.html.erb
View file @
168e4c7b
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<h2>
Edit
<%=
resource_name
.
to_s
.
humanize
%>
</h2>
<%=
simple_form_for
(
resource
,
as:
resource_name
,
url:
registration_path
(
resource_name
),
html:
{
method: :put
})
do
|
f
|
%>
...
...
election_2016/app/views/devise/registrations/new.html.erb
View file @
168e4c7b
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<h2>
Sign up
</h2>
<%=
simple_form_for
(
resource
,
as:
resource_name
,
url:
registration_path
(
resource_name
))
do
|
f
|
%>
...
...
@@ -7,7 +10,7 @@
<%=
f
.
input
:first_name
,
required:
true
,
autofocus:
true
%>
<%=
f
.
input
:last_name
,
required:
true
,
autofocus:
true
%>
<%=
f
.
input
:birthday
,
required:
true
,
autofocus:
true
%>
<%=
f
.
input
:gender
,
required:
true
,
autofocus:
true
%>
<%=
f
.
input
:gender
,
required:
true
,
a
s: :select
,
:collection
=>
[
'Female'
,
'Male'
]
a
utofocus:
true
%>
<%=
f
.
input
:email
,
required:
true
,
autofocus:
true
%>
<%=
f
.
input
:password
,
required:
true
,
hint:
(
"
#{
@minimum_password_length
}
characters minimum"
if
@minimum_password_length
)
%>
<%=
f
.
input
:password_confirmation
,
required:
true
%>
...
...
election_2016/app/views/devise/sessions/new.html.erb
View file @
168e4c7b
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<h2>
Log in
</h2>
<%=
simple_form_for
(
resource
,
as:
resource_name
,
url:
session_path
(
resource_name
))
do
|
f
|
%>
...
...
election_2016/app/views/devise/shared/_links.html.erb
View file @
168e4c7b
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<%-
if
controller_name
!=
'sessions'
%>
<%=
link_to
"Log in"
,
new_session_path
(
resource_name
)
%>
<br
/>
<%
end
-%>
...
...
election_2016/app/views/devise/unlocks/new.html.erb
View file @
168e4c7b
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<h2>
Resend unlock instructions
</h2>
<%=
simple_form_for
(
resource
,
as:
resource_name
,
url:
unlock_path
(
resource_name
),
html:
{
method: :post
})
do
|
f
|
%>
...
...
election_2016/app/views/pages/index.html.erb
View file @
168e4c7b
...
...
@@ -5,6 +5,7 @@
<div
class=
"box fade-in one"
>
<h1
style=
"margin-left:100px;margin-top:100px;font-family:Droid Sans"
>
Election 2016
</h1>
<h3
style=
"color:#0080ff;margin-left:100px"
>
...
...
@@ -32,6 +33,7 @@
<th>
First Name
</th>
<th>
Last Name
</th>
<th>
Slogan
</th>
<th>
Number of Votes
</th>
</tr>
<%
@candidates
.
each
do
|
candidate
|
%>
<tr>
...
...
@@ -39,6 +41,7 @@
<td>
<%=
candidate
.
first_name
%>
</td>
<td>
<%=
candidate
.
last_name
%>
</td>
<td>
<%=
candidate
.
slogan
%>
</td>
<td>
<%=
candidate
.
votes
.
count
%>
</td>
</tr>
<%
end
%>
</table>
...
...
election_2016/app/views/pages/profiles.html.erb
View file @
168e4c7b
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<h1>
Election 2016
</h1>
<h3>
Hello
<%=
current_user
.
last_name
%>
</h3>
<h3>
Hello
<%=
current_user
.
first_name
%>
<%=
current_user
.
last_name
%>
!
</h3>
<ul>
<li>
Email:
<%=
current_user
.
email
%>
</li>
<li>
Birthday:
<%=
current_user
.
birthday
%>
</li>
<li>
Sex:
<%=
current_user
.
gender
%>
</li>
<li>
Password:
<%=
current_user
.
password
%>
</li>
</ul>
<table
width=
"100%"
style=
"margin:100px;"
>
...
...
@@ -17,13 +24,13 @@
<td>
<%=
candidate
.
first_name
%>
</td>
<td>
<%=
candidate
.
last_name
%>
</td>
<td>
<%=
candidate
.
slogan
%>
</td>
<td>
<
!--<
td>
<%=
link_to
"Show "
,
candidate_path
(
candidate
.
id
)
%>
|
<%=
link_to
"Edit"
,
edit_candidate_path
(
candidate
.
id
)
%>
|
<%=
link_to
"Edit"
,
edit_candidate_path
(
candidate
.
id
)
%>
<%=
link_to
"Delete"
,
candidate_path
(
candidate
.
id
),
method: :delete
,
data:
{
confirm:
'Are you sure?'
}
%>
</td>
</td>
-->
</tr>
<%
end
%>
</table>
\ No newline at end of file
election_2016/app/views/pages/statistic.html.erb
deleted
100644 → 0
View file @
94a5cd72
<h1>
Voting Statistic
</h1>
\ No newline at end of file
election_2016/app/views/positions/_form.html.erb
View file @
168e4c7b
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<%=
simple_form_for
(
@position
)
do
|
p
|
%>
<%=
p
.
input
:name
,
as: :select
,
collection:
[
"President"
,
"Vice President"
,
"Senator"
]
%>
<%=
p
.
submit
%>
...
...
election_2016/app/views/positions/edit.html.erb
View file @
168e4c7b
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<h1>
Edit Candidate
</h1>
<%=
render
partial:
"form"
%>
...
...
election_2016/app/views/positions/new.html.erb
View file @
168e4c7b
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<h1>
Add Position
</h1>
<%=
render
partial:
"form"
%>
...
...
election_2016/app/views/positions/show.html.erb
View file @
168e4c7b
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<h1>
<%=
@position
.
name
%>
</h1>
...
...
election_2016/app/views/vote/vote.html.erb
0 → 100644
View file @
168e4c7b
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<h1>
Ballot
</h1>
<%
@candidates
.
each
do
|
position_id
,
candidates
|
%>
<%=
simple_form_for
(
@vote
,
url:
confirm_vote_path
,
method: :post
)
do
|
o
|
%>
<%=
Position
.
find
(
position_id
).
name
%>
<ul>
<li>
<%=
o
.
association
:candidate
,
:collection
=>
candidates
%>
</li>
<li>
<%=
o
.
input
:comments
%>
</li>
</ul>
<%=
o
.
button
:submit
,
"Vote"
%>
<%
end
%>
<%=
link_to
"Back"
,
candidates_list_path
%>
<%
end
%>
\ No newline at end of file
election_2016/app/views/vote/vote_record.erb
0 → 100644
View file @
168e4c7b
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<h1>
Voting Record of
<%=
current_user
.
first_name
%>
<%=
current_user
.
last_name
%>
</h1>
<table>
<thead>
<th>
Voted Candidate
</th>
<th>
Position
</th>
<th>
Voted On
</th>
</thead>
<tbody>
<%
@votes
.
each
do
|
o
|
%>
<tr>
<td>
<%=
o
.
candidate
.
first_name
%>
&
nbsp
<%=
o
.
candidate
.
last_name
%>
</td>
<td>
<%=
o
.
candidate
.
position
.
name
%>
</td>
<td>
<%=
o
.
created_at
%>
</td>
</tr>
<%
end
%>
</tbody>
</table>
election_2016/db/migrate/20160719105648_create_votes.rb
0 → 100644
View file @
168e4c7b
class
CreateVotes
<
ActiveRecord
::
Migration
def
change
create_table
:votes
do
|
t
|
t
.
integer
:user_id
t
.
integer
:candidate_id
t
.
text
:comments
t
.
timestamps
null:
false
end
end
end
election_2016/db/schema.rb
View file @
168e4c7b
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2016071
8054341
)
do
ActiveRecord
::
Schema
.
define
(
version:
2016071
9105648
)
do
create_table
"candidates"
,
force: :cascade
do
|
t
|
t
.
string
"first_name"
...
...
@@ -50,4 +50,12 @@ ActiveRecord::Schema.define(version: 20160718054341) do
add_index
"users"
,
[
"email"
],
name:
"index_users_on_email"
,
unique:
true
add_index
"users"
,
[
"reset_password_token"
],
name:
"index_users_on_reset_password_token"
,
unique:
true
create_table
"votes"
,
force: :cascade
do
|
t
|
t
.
integer
"user_id"
t
.
integer
"candidate_id"
t
.
text
"comments"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
end
end
election_2016/test/fixtures/votes.yml
0 → 100644
View file @
168e4c7b
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one
:
user_id
:
1
candidate_id
:
1
comments
:
MyText
two
:
user_id
:
1
candidate_id
:
1
comments
:
MyText
election_2016/test/models/vote_test.rb
0 → 100644
View file @
168e4c7b
require
'test_helper'
class
VoteTest
<
ActiveSupport
::
TestCase
# test "the truth" do
# assert true
# 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