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
9a919a4f
Commit
9a919a4f
authored
Jul 21, 2016
by
Galen Evilla
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
List of Users - made by galen
parent
0f4f790b
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
176 additions
and
47 deletions
+176
-47
candidates_controller.rb
Halalan-FINAL/app/controllers/admin/candidates_controller.rb
+1
-0
users_controller.rb
Halalan-FINAL/app/controllers/admin/users_controller.rb
+60
-0
users_controller.rb
Halalan-FINAL/app/controllers/users/users_controller.rb
+1
-0
index.html.erb
Halalan-FINAL/app/views/admin/users/index.html.erb
+51
-0
show.html.erb
Halalan-FINAL/app/views/admin/users/show.html.erb
+28
-0
_navbar.html.erb
Halalan-FINAL/app/views/layouts/_navbar.html.erb
+7
-0
index.html.erb
Halalan-FINAL/app/views/pages/index.html.erb
+3
-1
profile.html.erb
Halalan-FINAL/app/views/pages/profile.html.erb
+21
-12
_user.html.erb
Halalan-FINAL/app/views/users/_user.html.erb
+0
-12
index.html.erb
Halalan-FINAL/app/views/users/index.html.erb
+0
-16
show.html.erb
Halalan-FINAL/app/views/users/show.html.erb
+0
-3
index.html.erb
Halalan-FINAL/app/views/voting/votes/index.html.erb
+3
-1
routes.rb
Halalan-FINAL/config/routes.rb
+1
-2
No files found.
Halalan-FINAL/app/controllers/admin/candidates_controller.rb
View file @
9a919a4f
...
...
@@ -32,6 +32,7 @@ module Admin
@candidate
.
votes
.
each
do
|
v
|
v
.
destroy!
end
@candidate
.
destroy!
redirect_to
admin_candidates_path
end
...
...
Halalan-FINAL/app/controllers/admin/users_controller.rb
0 → 100644
View file @
9a919a4f
module
Admin
class
UsersController
<
ApplicationController
before_action
:authenticate_user!
def
index
@positions
=
Position
.
all
@candidates
=
Candidate
.
all
@votes
=
Vote
.
all
@users
=
User
.
all
render
"admin/users/index.html.erb"
end
def
new
@user
=
User
.
new
render
"admin/users/new.html.erb"
end
def
edit
@user
=
User
.
find
(
params
[
:id
])
end
def
update
@user
=
User
.
find
(
params
[
:id
])
if
@user
.
update
(
position_params
())
redirect_to
admin_users_path
(
@user
.
id
)
else
render
"admin/user/edit.html.erb"
end
end
def
destroy
@candidate
=
User
.
find
(
params
[
:id
])
@candidate
.
destroy!
redirect_to
admin_users_path
end
def
create
@user
=
User
.
new
(
position_params
())
if
@user
.
save
redirect_to
admin_user_path
(
@user
.
id
)
else
render
"admin/users/new.html.erb"
end
end
def
show
@positions
=
Position
.
all
@candidates
=
Candidate
.
all
@votes
=
Vote
.
all
@user
=
User
.
find
(
params
[
:id
])
render
"admin/users/show.html.erb"
end
def
user_params
params
.
require
(
:user
).
permit!
end
end
end
\ No newline at end of file
Halalan-FINAL/app/controllers/users/users_controller.rb
View file @
9a919a4f
...
...
@@ -5,6 +5,7 @@ module Users
@positions
=
Position
.
all
@candidates
=
Candidate
.
all
@votes
=
Vote
.
all
@currentuser
=
current_user
render
"pages/profile.html.erb"
end
end
...
...
Halalan-FINAL/app/views/admin/users/index.html.erb
0 → 100644
View file @
9a919a4f
<%
provide
(
:title
,
"Users"
)
%>
<div
class=
"container"
>
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<h1>
Users
</h1>
<hr>
<%
@users
.
each
do
|
u
|
%>
<ul>
<li>
User ID:
<%=
u
.
id
%>
</li>
<li>
Full Name:
<%=
u
.
full_name
%>
</li>
<li>
Candidates Voted:
<ul>
<%
u
.
votes
.
each
do
|
v
|
%>
<li>
<%=
v
.
candidate
.
full_name
%>
-
<%=
v
.
candidate
.
position
.
name
%>
</li>
<%
end
%>
</ul>
</li>
<li>
Actions:
<ul>
<%
if
current_user
.
id
==
u
.
id
%>
<div
class=
"btn btn-info"
role =
"button"
>
<%=
link_to
"Show Your Profile"
,
admin_user_path
(
u
.
id
)
%>
</div>
<div
class=
"btn btn-danger"
role =
"button"
>
<%=
link_to
"Cannot Delete Your Own!"
%>
</div>
<%
else
%>
<div
class=
"btn btn-info"
role =
"button"
>
<%=
link_to
"Show User's Profile"
,
admin_user_path
(
u
.
id
)
%>
</div>
<div
class=
"btn btn-info"
role =
"button"
>
<%=
link_to
"Delete User"
,
admin_user_path
(
u
.
id
),
method: :delete
,
data:
{
confirm:
'Are you sure?'
}
%>
</div>
<%
end
%>
</ul>
</li>
</ul>
<hr>
<%
end
%>
</div>
</div>
</div>
Halalan-FINAL/app/views/admin/users/show.html.erb
0 → 100644
View file @
9a919a4f
<%
provide
(
:title
,
"
#{
@user
.
full_name
}
"
)
%>
<div
class=
"container"
>
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<%
if
@user
.
votes
.
size
>
0
%>
<%
@user
.
votes
.
each
do
|
v
|
%>
<li>
<%=
"
#{
v
.
candidate
.
position
.
name
}
:
#{
v
.
candidate
.
full_name
}
"
%>
<p>
Comments:
<%=
v
.
comment
%>
</p>
</li>
<%
end
%>
<%
else
%>
<center>
<%
if
current_user
.
id
==
@user
.
id
%>
<h4>
<%=
link_to
"You haven't voted for any candidates yet. Vote Now!"
,
"/voting/votes"
%>
</h4>
<%
else
%>
<h4>
<%=
user
.
full_name
%>
has not casted their votes yet %>
</h4>
<%
end
%>
</center>
<%
end
%>
</div>
</div>
</div>
\ No newline at end of file
Halalan-FINAL/app/views/layouts/_navbar.html.erb
View file @
9a919a4f
...
...
@@ -29,6 +29,13 @@
</u1>
</ul>
</li>
<li
class=
"dropdown"
>
<a
href=
"#"
class=
"dropdown-toggle"
data-toggle=
"dropdown"
>
Admin Stuff
<b
class=
"caret"
></b></a>
<ul
class=
"dropdown-menu"
>
<li>
<%=
link_to
"List of Users"
,
admin_users_path
%>
</li>
</u1>
</ul>
</li>
<%
else
%>
<li>
<%=
link_to
"Log-in"
,
new_user_session_path
%>
</li>
<li>
<%=
link_to
"Register"
,
new_user_registration_path
%>
</li>
...
...
Halalan-FINAL/app/views/pages/index.html.erb
View file @
9a919a4f
...
...
@@ -30,6 +30,8 @@
</table>
<hr>
<%
end
%>
<%=
link_to
"List of Users"
,
admin_users_path
%>
</div>
</div>
</div>
\ No newline at end of file
</div>
Halalan-FINAL/app/views/pages/profile.html.erb
View file @
9a919a4f
<%
provide
(
:title
,
"
#{
@currentuser
.
full_name
}
"
)
%>
<div
class =
"container"
>
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<h2>
Hey
<%=
current_user
.
first_name
%>
!
</h2>
<br>
You Voted for:
<br>
<ul>
<%
current_user
.
votes
.
each
do
|
v
|
%>
<li>
<%=
"
#{
v
.
candidate
.
position
.
name
}
:
#{
v
.
candidate
.
full_name
}
"
%>
<p>
Comments:
<%=
v
.
comment
%>
</p>
</li>
<%
end
%>
</ul>
<%
if
@currentuser
.
votes
.
size
>
0
%>
You Voted for:
<br>
<ul>
<%
current_user
.
votes
.
each
do
|
v
|
%>
<li>
<%=
"
#{
v
.
candidate
.
position
.
name
}
:
#{
v
.
candidate
.
full_name
}
"
%>
<p>
Comments:
<%=
v
.
comment
%>
</p>
</li>
<%
end
%>
</ul>
<%
else
%>
<center>
<h4>
<%=
link_to
"You haven't voted for any candidates yet. Vote Now!"
,
"/voting/votes"
%>
</h4>
</center>
<%
end
%>
</div>
</div>
</div>
\ No newline at end of file
Halalan-FINAL/app/views/users/_user.html.erb
deleted
100644 → 0
View file @
0f4f790b
<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
deleted
100644 → 0
View file @
0f4f790b
<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
deleted
100644 → 0
View file @
0f4f790b
<h3>
User
</h3>
<p>
Name:
<%=
@user
.
name
if
@user
.
name
%>
</p>
<p>
Email:
<%=
@user
.
email
if
@user
.
email
%>
</p>
Halalan-FINAL/app/views/voting/votes/index.html.erb
View file @
9a919a4f
...
...
@@ -24,7 +24,9 @@
<%
end
%>
<%
end
%>
<%
if
!
voted_for
%>
<%=
link_to
"Vote for a
#{
p
.
name
}
"
,
"/voting/new/
#{
p
.
id
}
"
%>
<div
class=
"btn btn-info"
role =
"button"
>
<%=
link_to
"Vote for a
#{
p
.
name
}
"
,
"/voting/new/
#{
p
.
id
}
"
%>
</div>
<%
else
%>
<%
end
%>
<%
else
%>
...
...
Halalan-FINAL/config/routes.rb
View file @
9a919a4f
...
...
@@ -3,8 +3,6 @@ Rails.application.routes.draw do
devise_for
:users
resources
:users
get
"/profile"
,
to:
"users/users#index"
get
"/voting/new/:id"
,
to:
"voting/votes#new"
...
...
@@ -23,5 +21,6 @@ Rails.application.routes.draw do
namespace
:admin
do
resources
:candidates
resources
:positions
resources
:users
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