Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
final_project
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
evilla_gomez_guian_principe
final_project
Commits
2b896259
Commit
2b896259
authored
Jul 21, 2016
by
April Guian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Jasmine's Individual Task
parent
47ab9dcc
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
62 additions
and
72 deletions
+62
-72
Gemfile
Halalan-FINAL/Gemfile
+1
-1
Gemfile.lock
Halalan-FINAL/Gemfile.lock
+2
-2
users_controller.rb
Halalan-FINAL/app/controllers/admin/users_controller.rb
+12
-2
users_controller.rb
Halalan-FINAL/app/controllers/users_controller.rb
+0
-45
candidate.rb
Halalan-FINAL/app/models/candidate.rb
+2
-2
user.rb
Halalan-FINAL/app/models/user.rb
+0
-7
show.html.erb
Halalan-FINAL/app/views/admin/candidates/show.html.erb
+2
-2
profile.html.erb
Halalan-FINAL/app/views/pages/profile.html.erb
+11
-11
_user.html.erb
Halalan-FINAL/app/views/users/_user.html.erb
+12
-0
index.html.erb
Halalan-FINAL/app/views/users/index.html.erb
+16
-0
show.html.erb
Halalan-FINAL/app/views/users/show.html.erb
+3
-0
routes.rb
Halalan-FINAL/config/routes.rb
+1
-0
No files found.
Halalan-FINAL/Gemfile
View file @
2b896259
source
'http
s
://rubygems.org'
source
'http://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
...
...
Halalan-FINAL/Gemfile.lock
View file @
2b896259
GEM
GEM
remote: http
s
://rubygems.org/
remote: http://rubygems.org/
specs:
specs:
actioncable (5.0.0)
actioncable (5.0.0)
actionpack (= 5.0.0)
actionpack (= 5.0.0)
...
@@ -190,4 +190,4 @@ DEPENDENCIES
...
@@ -190,4 +190,4 @@ DEPENDENCIES
web-console
web-console
BUNDLED WITH
BUNDLED WITH
1.1
2.5
1.1
0.4
Halalan-FINAL/app/controllers/admin/users_controller.rb
View file @
2b896259
...
@@ -4,8 +4,8 @@ module Admin
...
@@ -4,8 +4,8 @@ module Admin
def
index
def
index
@positions
=
Position
.
all
@positions
=
Position
.
all
@candidates
=
Candidate
.
all
@candidates
=
Candidate
.
all
@votes
=
Vote
.
all
@users
=
User
.
all
@users
=
User
.
all
@votes
=
Vote
.
all
render
"admin/users/index.html.erb"
render
"admin/users/index.html.erb"
end
end
...
@@ -52,6 +52,16 @@ module Admin
...
@@ -52,6 +52,16 @@ module Admin
render
"admin/users/show.html.erb"
render
"admin/users/show.html.erb"
end
end
#def destroy
# @user = User.find(params[:id])
# @user.votes.each do |v|
# v.destroy!
# end
# @user.destroy!
# redirect_to admin_users_path
#end
def
user_params
def
user_params
params
.
require
(
:user
).
permit!
params
.
require
(
:user
).
permit!
...
...
Halalan-FINAL/app/controllers/users_controller.rb
deleted
100644 → 0
View file @
47ab9dcc
class
UsersController
<
ApplicationController
before_filter
:authenticate_user!
before_filter
:admin_only
,
:except
=>
:show
def
index
@users
=
User
.
all
end
def
show
@user
=
User
.
find
(
params
[
:id
])
unless
current_user
.
admin?
unless
@user
==
current_user
redirect_to
:back
,
:alert
=>
"Access denied."
end
end
end
def
update
@user
=
User
.
find
(
params
[
:id
])
if
@user
.
update_attributes
(
secure_params
)
redirect_to
users_path
,
:notice
=>
"User updated."
else
redirect_to
users_path
,
:alert
=>
"Unable to update user."
end
end
def
destroy
user
=
User
.
find
(
params
[
:id
])
user
.
destroy
redirect_to
users_path
,
:notice
=>
"User deleted."
end
private
def
admin_only
unless
current_user
.
admin?
redirect_to
root_path
,
:alert
=>
"Access denied."
end
end
def
secure_params
params
.
require
(
:user
).
permit
(
:role
)
end
end
\ No newline at end of file
Halalan-FINAL/app/models/candidate.rb
View file @
2b896259
...
@@ -18,8 +18,8 @@ class Candidate < ApplicationRecord
...
@@ -18,8 +18,8 @@ class Candidate < ApplicationRecord
votes
.
select
{
|
vote
|
vote
.
user
.
gender
==
'Female'
}
votes
.
select
{
|
vote
|
vote
.
user
.
gender
==
'Female'
}
end
end
def
other_votes
def
other
s
_votes
votes
.
select
{
|
vote
|
vote
.
user
.
gender
==
'Other'
}
votes
.
select
{
|
vote
|
vote
.
user
.
gender
==
'Other
s
'
}
end
end
end
end
Halalan-FINAL/app/models/user.rb
View file @
2b896259
class
User
<
ApplicationRecord
class
User
<
ApplicationRecord
enum
role:
{
voter:
0
,
admin:
1
}
after_initialize
:set_default_role
,
:if
=>
:new_record?
def
set_default_role
self
.
role
||=
:voter
end
has_many
:votes
,
dependent: :destroy
has_many
:votes
,
dependent: :destroy
devise
:database_authenticatable
,
:registerable
,
devise
:database_authenticatable
,
:registerable
,
...
...
Halalan-FINAL/app/views/admin/candidates/show.html.erb
View file @
2b896259
...
@@ -40,7 +40,7 @@
...
@@ -40,7 +40,7 @@
<tr>
<tr>
<td><center>
<%=
@candidate
.
male_votes
.
size
%>
Votes
<br>
<progress
value=
"
<%=
@candidate
.
male_votes
.
size
%>
"
max=
"
<%=
@candidate
.
votes
.
count
%>
"
></center></td>
<td><center>
<%=
@candidate
.
male_votes
.
size
%>
Votes
<br>
<progress
value=
"
<%=
@candidate
.
male_votes
.
size
%>
"
max=
"
<%=
@candidate
.
votes
.
count
%>
"
></center></td>
<td><center>
<%=
@candidate
.
female_votes
.
size
%>
Votes
<br>
<progress
value=
"
<%=
@candidate
.
female_votes
.
size
%>
"
max=
"
<%=
@candidate
.
votes
.
count
%>
"
></center></td>
<td><center>
<%=
@candidate
.
female_votes
.
size
%>
Votes
<br>
<progress
value=
"
<%=
@candidate
.
female_votes
.
size
%>
"
max=
"
<%=
@candidate
.
votes
.
count
%>
"
></center></td>
<td><center>
<%=
@candidate
.
other
_votes
.
size
%>
Votes
<br>
<progress
value=
"
<%=
@candidate
.
other
_votes
.
size
%>
"
max=
"
<%=
@candidate
.
votes
.
count
%>
"
></center></td>
<td><center>
<%=
@candidate
.
other
s_votes
.
size
%>
Votes
<br>
<progress
value=
"
<%=
@candidate
.
others
_votes
.
size
%>
"
max=
"
<%=
@candidate
.
votes
.
count
%>
"
></center></td>
<td><center>
<%=
@candidate
.
votes
.
count
%>
</center></td>
<td><center>
<%=
@candidate
.
votes
.
count
%>
</center></td>
</tr>
</tr>
</table>
</table>
...
@@ -51,7 +51,7 @@
...
@@ -51,7 +51,7 @@
<ul>
<ul>
<li>
<li>
<%
@candidate
.
votes
.
each
do
|
v
|
%>
<%
@candidate
.
votes
.
each
do
|
v
|
%>
Voter ID:
<%=
"
#{
v
.
user_id
}
"
%>
<%=
"
#{
v
.
user_id
}
"
%>
<br>
<br>
<p>
<p>
Comments:
<%=
v
.
comment
%>
Comments:
<%=
v
.
comment
%>
...
...
Halalan-FINAL/app/views/pages/profile.html.erb
View file @
2b896259
Halalan-FINAL/app/views/users/_user.html.erb
0 → 100644
View file @
2b896259
<td>
<%=
link_to
user
.
email
,
user
%>
</td>
<td>
<%=
form_for
(
user
)
do
|
f
|
%>
<%=
f
.
select
(
:role
,
User
.
roles
.
keys
.
map
{
|
role
|
[
role
.
titleize
,
role
]})
%>
<%=
f
.
submit
'Change Role'
,
:class
=>
'button-xs'
%>
<%
end
%>
</td>
<td>
<%=
link_to
(
"Delete user"
,
user_path
(
user
),
:data
=>
{
:confirm
=>
"Are you sure?"
},
:method
=>
:delete
,
:class
=>
'button-xs'
)
unless
user
==
current_user
%>
</td>
\ No newline at end of file
Halalan-FINAL/app/views/users/index.html.erb
0 → 100644
View file @
2b896259
<div
class=
"container"
>
<div
class=
"row"
>
<h3>
Users
</h3>
<div
class=
"column"
>
<table
class=
"table"
>
<tbody>
<%
@users
.
each
do
|
user
|
%>
<tr>
<%=
render
user
%>
</tr>
<%
end
%>
</tbody>
</table>
</div>
</div>
</div>
\ No newline at end of file
Halalan-FINAL/app/views/users/show.html.erb
0 → 100644
View file @
2b896259
<h3>
User
</h3>
<p>
Name:
<%=
@user
.
name
if
@user
.
name
%>
</p>
<p>
Email:
<%=
@user
.
email
if
@user
.
email
%>
</p>
Halalan-FINAL/config/routes.rb
View file @
2b896259
...
@@ -12,6 +12,7 @@ Rails.application.routes.draw do
...
@@ -12,6 +12,7 @@ Rails.application.routes.draw do
get
"/about/guian"
,
to:
"about#guian"
get
"/about/guian"
,
to:
"about#guian"
get
"/about/principe"
,
to:
"about#principe"
get
"/about/principe"
,
to:
"about#principe"
get
"/admin/users"
,
to:
"admin/users#index"
namespace
:voting
do
namespace
:voting
do
resources
:votes
resources
:votes
...
...
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