Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
candi-date-tayo
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
George Nicole Balmaceda
candi-date-tayo
Commits
dc7d9ddd
Commit
dc7d9ddd
authored
Jul 18, 2016
by
George Nicole Balmaceda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added admin
parent
48197d5d
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
204 additions
and
0 deletions
+204
-0
candidates_controller.rb
app/controllers/admin/candidates_controller.rb
+55
-0
positions_controller.rb
app/controllers/admin/positions_controller.rb
+57
-0
candidate-index.html.erb
app/views/admin/candidate-index.html.erb
+0
-0
_form.html.erb
app/views/admin/candidates/_form.html.erb
+10
-0
edit.html.erb
app/views/admin/candidates/edit.html.erb
+5
-0
index.html.erb
app/views/admin/candidates/index.html.erb
+20
-0
new.html.erb
app/views/admin/candidates/new.html.erb
+4
-0
show.html.erb
app/views/admin/candidates/show.html.erb
+13
-0
_form.html.erb
app/views/admin/positions/_form.html.erb
+7
-0
edit.html.erb
app/views/admin/positions/edit.html.erb
+5
-0
index.html.erb
app/views/admin/positions/index.html.erb
+14
-0
new.html.erb
app/views/admin/positions/new.html.erb
+4
-0
show.html.erb
app/views/admin/positions/show.html.erb
+10
-0
No files found.
app/controllers/admin/candidates_controller.rb
0 → 100644
View file @
dc7d9ddd
module
Admin
class
CandidatesController
<
ApplicationController
def
index
@positions
=
Position
.
all
render
"admin/candidates/index.html.erb"
end
def
new
@candidate
=
Candidate
.
new
render
"admin/candidates/new.html.erb"
end
def
edit
@candidate
=
Candidate
.
find
(
params
[
:id
])
end
def
update
@candidate
=
Candidate
.
find
(
params
[
:id
])
if
@candidate
.
update
(
candidate_params
())
redirect_to
admin_candidates_path
(
@candidate
.
id
)
else
render
"admin/candidates/edit.html.erb"
end
end
def
destroy
@candidate
=
Candidate
.
find
(
params
[
:id
])
@candidate
.
destroy!
redirect_to
admin_candidates_path
end
def
create
@candidate
=
Candidate
.
new
(
candidate_params
())
if
@candidate
.
save
redirect_to
admin_candidate_path
(
@candidate
.
id
)
else
render
"admin/candidates/new.html.erb"
end
end
def
show
@candidate
=
Candidate
.
find
(
params
[
:id
])
render
"admin/candidates/show.html.erb"
end
def
candidate_params
params
.
require
(
:candidate
).
permit!
end
end
end
\ No newline at end of file
app/controllers/admin/positions_controller.rb
0 → 100644
View file @
dc7d9ddd
module
Admin
class
PositionsController
<
ApplicationController
def
index
@positions
=
Position
.
all
render
"admin/positions/index.html.erb"
end
def
new
@position
=
Position
.
new
render
"admin/positions/new.html.erb"
end
def
edit
@position
=
Position
.
find
(
params
[
:id
])
end
def
update
@position
=
Position
.
find
(
params
[
:id
])
if
@position
.
update
(
position_params
())
redirect_to
admin_positions_path
(
@position
.
id
)
else
render
"admin/position/edit.html.erb"
end
end
def
destroy
@candidate
=
Position
.
find
(
params
[
:id
])
@candidate
.
destroy!
redirect_to
admin_positions_path
end
def
create
@position
=
Position
.
new
(
position_params
())
if
@position
.
save
redirect_to
admin_position_path
(
@position
.
id
)
else
render
"admin/positions/new.html.erb"
end
end
def
show
@position
=
Position
.
find
(
params
[
:id
])
render
"admin/positions/show.html.erb"
end
def
position_params
params
.
require
(
:position
).
permit!
end
end
end
app/views/admin/candidate-index.html.erb
0 → 100644
View file @
dc7d9ddd
app/views/admin/candidates/_form.html.erb
0 → 100755
View file @
dc7d9ddd
<%=
simple_form_for
([
:admin
,
@candidate
])
do
|
f
|
%>
I wanna vote for
<%=
f
.
association
:position
,
label_method: :name
,
value_method: :id
%>
<%=
f
.
input
:first_name
%>
<%=
f
.
input
:last_name
%>
<%=
f
.
input
:slogan
%>
<%=
f
.
submit
%>
<%
end
%>
app/views/admin/candidates/edit.html.erb
0 → 100755
View file @
dc7d9ddd
<h1>
Admin Edit Post
</h1>
<%=
render
partial:
"form"
%>
<%=
link_to
"Back to Candidates"
,
admin_candidates_path
%>
\ No newline at end of file
app/views/admin/candidates/index.html.erb
0 → 100755
View file @
dc7d9ddd
<h4>
Displaying All Candidates Grouped By Positions
</h4>
<%=
link_to
"+ new Candidate"
,
new_admin_candidate_path
%>
<div
class=
"container"
>
<%
@positions
.
each
do
|
p
|
%>
<div
style=
"display:inline-block; border:solid 1px; padding:40px; bottom:0; width:140px; margin:20px;"
>
<h5>
<%=
p
.
name
%>
</h5>
<ul
>
<%
p
.
candidates
.
each
do
|
c
|
%>
<li>
<%=
link_to
c
.
full_name
,
admin_candidate_path
(
c
.
id
)
%>
</li>
<%
end
%>
</ul>
</div>
<%
end
%>
</div>
\ No newline at end of file
app/views/admin/candidates/new.html.erb
0 → 100755
View file @
dc7d9ddd
<h1>
New Candidate
</h1>
<%=
render
partial:
"form"
%>
app/views/admin/candidates/show.html.erb
0 → 100755
View file @
dc7d9ddd
<h1
style=
"margin-bottom:3px;"
>
<%=
@candidate
.
full_name
%>
<%=
link_to
"Edit"
,
edit_admin_candidate_path
(
@candidate
.
id
),
{
:style
=>
"font-size:18px; text-decoration:none; color:rgba(0,0,0,0.5)"
}
%>
<%=
link_to
"OBOSEN"
,
admin_candidate_path
(
@candidate
.
id
),
{
:style
=>
"font-size:18px; text-decoration:none; color:rgba(200,0,0,0.5)"
,
method: :delete
}
%>
</h1>
<h3
style=
"margin-top:3px; color:#004e7e"
>
<%=
@candidate
.
position
.
name
%>
</h3>
<p>
<%=
@candidate
.
slogan
%>
</p>
<hr>
<%=
link_to
"Back to Candidates"
,
admin_candidates_path
%>
app/views/admin/positions/_form.html.erb
0 → 100755
View file @
dc7d9ddd
<%=
simple_form_for
([
:admin
,
@position
])
do
|
f
|
%>
<%=
f
.
input
:name
%>
<%=
f
.
submit
%>
<%
end
%>
app/views/admin/positions/edit.html.erb
0 → 100755
View file @
dc7d9ddd
<h1>
Admin Edit Post
</h1>
<%=
render
partial:
"form"
%>
<%=
link_to
"Back to Candidates"
,
admin_candidates_path
%>
\ No newline at end of file
app/views/admin/positions/index.html.erb
0 → 100755
View file @
dc7d9ddd
<h4>
Positions from the Vote-a-Sutra
</h4>
<%=
link_to
"+ new Position"
,
new_admin_position_path
%>
<div
class=
"container"
>
<%
@positions
.
each
do
|
p
|
%>
<div
style=
""
>
<a
href=
"#"
>
<%=
link_to
p
.
name
,
admin_position_path
(
p
.
id
)
%>
</a>
</ul>
</div>
<%
end
%>
</div>
\ No newline at end of file
app/views/admin/positions/new.html.erb
0 → 100755
View file @
dc7d9ddd
<h1>
New Candidate
</h1>
<%=
render
partial:
"form"
%>
app/views/admin/positions/show.html.erb
0 → 100755
View file @
dc7d9ddd
<h1
style=
"margin-bottom:3px;"
>
<%=
@position
.
name
%>
<%=
link_to
"Edit"
,
edit_admin_position_path
(
@position
.
id
),
{
:style
=>
"font-size:18px; text-decoration:none; color:rgba(0,0,0,0.5)"
}
%>
<%=
link_to
"OBOSEN"
,
admin_position_path
(
@position
.
id
),
{
:style
=>
"font-size:18px; text-decoration:none; color:rgba(200,0,0,0.5)"
,
method: :delete
}
%>
</h1>
<%
@position
.
candidates
.
each
do
|
c
|
%>
<li>
<%=
link_to
c
.
full_name
,
admin_candidate_path
(
c
.
id
)
%>
</li>
<%
end
%>
<%=
link_to
"Back to Positions"
,
admin_positions_path
%>
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