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
26f76714
Commit
26f76714
authored
Jul 21, 2016
by
Wills Gomez
Browse files
Options
Browse Files
Download
Plain Diff
fixed profile for finals
parents
475f9ba1
9a919a4f
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
179 additions
and
35 deletions
+179
-35
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
+24
-0
_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 @
26f76714
...
@@ -32,6 +32,7 @@ module Admin
...
@@ -32,6 +32,7 @@ module Admin
@candidate
.
votes
.
each
do
|
v
|
@candidate
.
votes
.
each
do
|
v
|
v
.
destroy!
v
.
destroy!
end
end
@candidate
.
destroy!
@candidate
.
destroy!
redirect_to
admin_candidates_path
redirect_to
admin_candidates_path
end
end
...
...
Halalan-FINAL/app/controllers/admin/users_controller.rb
0 → 100644
View file @
26f76714
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 @
26f76714
...
@@ -5,6 +5,7 @@ module Users
...
@@ -5,6 +5,7 @@ module Users
@positions
=
Position
.
all
@positions
=
Position
.
all
@candidates
=
Candidate
.
all
@candidates
=
Candidate
.
all
@votes
=
Vote
.
all
@votes
=
Vote
.
all
@currentuser
=
current_user
render
"pages/profile.html.erb"
render
"pages/profile.html.erb"
end
end
end
end
...
...
Halalan-FINAL/app/views/admin/users/index.html.erb
0 → 100644
View file @
26f76714
<%
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 @
26f76714
<%
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 @
26f76714
...
@@ -29,6 +29,13 @@
...
@@ -29,6 +29,13 @@
</u1>
</u1>
</ul>
</ul>
</li>
</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
%>
<%
else
%>
<li>
<%=
link_to
"Log-in"
,
new_user_session_path
%>
</li>
<li>
<%=
link_to
"Log-in"
,
new_user_session_path
%>
</li>
<li>
<%=
link_to
"Register"
,
new_user_registration_path
%>
</li>
<li>
<%=
link_to
"Register"
,
new_user_registration_path
%>
</li>
...
...
Halalan-FINAL/app/views/pages/index.html.erb
View file @
26f76714
...
@@ -30,6 +30,8 @@
...
@@ -30,6 +30,8 @@
</table>
</table>
<hr>
<hr>
<%
end
%>
<%
end
%>
<%=
link_to
"List of Users"
,
admin_users_path
%>
</div>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
Halalan-FINAL/app/views/pages/profile.html.erb
View file @
26f76714
<%
provide
(
:title
,
"
#{
@currentuser
.
full_name
}
"
)
%>
<div
class =
"container"
>
<div
class =
"container"
>
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<div
class=
"col-md-12"
>
<h2>
Hey
<%=
current_user
.
first_name
%>
!
</h2>
<h2>
Hey
<%=
current_user
.
first_name
%>
!
</h2>
<br>
<br>
<
<<<<<<
HEAD
<
h4
>
You Voted for:
</h4>
<
h4
>
You Voted for:
</h4>
<br>
<br>
<ul>
<ul>
...
@@ -34,6 +38,26 @@
...
@@ -34,6 +38,26 @@
<h5></h5>
<h5></h5>
<%
end
%>
<%
end
%>
</ul>
</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
%>
>>>>>>> 9a919a4f1954bbaa640bd8813e4bc205c39e1657
</div>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
Halalan-FINAL/app/views/users/_user.html.erb
deleted
100644 → 0
View file @
475f9ba1
<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 @
475f9ba1
<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 @
475f9ba1
<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 @
26f76714
...
@@ -24,7 +24,9 @@
...
@@ -24,7 +24,9 @@
<%
end
%>
<%
end
%>
<%
end
%>
<%
end
%>
<%
if
!
voted_for
%>
<%
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
%>
<%
else
%>
<%
end
%>
<%
end
%>
<%
else
%>
<%
else
%>
...
...
Halalan-FINAL/config/routes.rb
View file @
26f76714
...
@@ -3,8 +3,6 @@ Rails.application.routes.draw do
...
@@ -3,8 +3,6 @@ Rails.application.routes.draw do
devise_for
:users
devise_for
:users
resources
:users
get
"/profile"
,
to:
"users/users#index"
get
"/profile"
,
to:
"users/users#index"
get
"/voting/new/:id"
,
to:
"voting/votes#new"
get
"/voting/new/:id"
,
to:
"voting/votes#new"
...
@@ -23,5 +21,6 @@ Rails.application.routes.draw do
...
@@ -23,5 +21,6 @@ Rails.application.routes.draw do
namespace
:admin
do
namespace
:admin
do
resources
:candidates
resources
:candidates
resources
:positions
resources
:positions
resources
:users
end
end
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