Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
Final-Elections-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
Christiana Tan
Final-Elections-Project
Commits
c4ba16d8
Commit
c4ba16d8
authored
Jul 15, 2016
by
Christiana Tan
Browse files
Options
Browse Files
Download
Plain Diff
New update
parents
e3fdc7e2
eab438a6
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
315 additions
and
5 deletions
+315
-5
Gemfile.lock
Gemfile.lock
+22
-0
candidates_controller.rb
app/controllers/candidates_controller.rb
+26
-0
user.rb
app/models/user.rb
+10
-0
vote.rb
app/models/vote.rb
+6
-0
edit.html.erb
app/views/candidates/edit.html.erb
+5
-0
index.html.erb
app/views/candidates/index.html.erb
+56
-0
new.html.erb
app/views/candidates/new.html.erb
+48
-1
application.html.erb
app/views/layouts/application.html.erb
+3
-0
_form.html.erb
app/views/positions/_form.html.erb
+13
-0
edit.html.erb
app/views/positions/edit.html.erb
+21
-1
index.html.erb
app/views/positions/index.html.erb
+26
-1
new.html.erb
app/views/positions/new.html.erb
+7
-1
show.html.erb
app/views/positions/show.html.erb
+30
-1
routes.rb
config/routes.rb
+42
-0
No files found.
Gemfile.lock
View file @
c4ba16d8
...
...
@@ -37,6 +37,10 @@ GEM
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.3)
<<<<<<< HEAD
=======
bcrypt (3.1.11)
>>>>>>> eab438a60d774a5c3833f57eff50b31b57c6cd5c
bcrypt (3.1.11-x86-mingw32)
better_errors (2.1.1)
coderay (>= 1.0.0)
...
...
@@ -85,6 +89,12 @@ GEM
mini_portile2 (2.1.0)
minitest (5.9.0)
multi_json (1.12.1)
<<<<<<< HEAD
=======
nokogiri (1.6.8)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
>>>>>>> eab438a60d774a5c3833f57eff50b31b57c6cd5c
nokogiri (1.6.8-x86-mingw32)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
...
...
@@ -142,6 +152,10 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
<<<<<<< HEAD
=======
sqlite3 (1.3.11)
>>>>>>> eab438a60d774a5c3833f57eff50b31b57c6cd5c
sqlite3 (1.3.11-x86-mingw32)
thor (0.19.1)
thread_safe (0.3.5)
...
...
@@ -164,6 +178,10 @@ GEM
sprockets-rails (>= 2.0, < 4.0)
PLATFORMS
<<<<<<< HEAD
=======
ruby
>>>>>>> eab438a60d774a5c3833f57eff50b31b57c6cd5c
x86-mingw32
DEPENDENCIES
...
...
@@ -184,4 +202,8 @@ DEPENDENCIES
web-console (~> 2.0)
BUNDLED WITH
<<<<<<< HEAD
1.10.4
=======
1.12.5
>>>>>>> eab438a60d774a5c3833f57eff50b31b57c6cd5c
app/controllers/candidates_controller.rb
View file @
c4ba16d8
class
CandidatesController
<
ApplicationController
<<<<<<<
HEAD
before_action
:authenticate_admin!
,
except:
[
:index
]
=======
before_action
:authenticate_user!
,
only:
[
:vote
]
#or except
before_action
:authenticate_admin!
,
except:
[
:index
]
>>>>>>>
eab438a60d774a5c3833f57eff50b31b57c6cd5c
def
index
@candidates
=
Candidate
.
all
end
<<<<<<<
HEAD
=======
def
vote
end
>>>>>>>
eab438a60d774a5c3833f57eff50b31b57c6cd5c
def
new
@candidate
=
Candidate
.
new
end
...
...
@@ -13,7 +24,11 @@ class CandidatesController < ApplicationController
@candidate
=
Candidate
.
new
(
candidate_params
)
if
@candidate
.
save
<<<<<<<
HEAD
redirect_to
candidates_path
,
notice:
"User was successfully created"
=======
redirect_to
candidate_path
(
@candidate
),
notice:
"User was successfully created"
>>>>>>>
eab438a60d774a5c3833f57eff50b31b57c6cd5c
else
render
'new'
end
...
...
@@ -23,11 +38,16 @@ class CandidatesController < ApplicationController
@candidate
=
Candidate
.
find
(
params
[
:id
])
@candidate
.
destroy
()
<<<<<<<
HEAD
redirect_to
candidates_path
=======
redirect_to
candidate_path
>>>>>>>
eab438a60d774a5c3833f57eff50b31b57c6cd5c
end
def
edit
<<<<<<<
HEAD
@candidate
=
Candidate
.
find
(
params
[
:id
])
end
...
...
@@ -39,6 +59,12 @@ class CandidatesController < ApplicationController
else
render
'edit'
end
=======
@candidate
=
Candidate
.
find
(
params
[
:id
])
end
def
update
>>>>>>>
eab438a60d774a5c3833f57eff50b31b57c6cd5c
end
def
show
...
...
app/models/user.rb
View file @
c4ba16d8
...
...
@@ -5,5 +5,15 @@ class User < ActiveRecord::Base
devise
:database_authenticatable
,
:registerable
,
:recoverable
,
:rememberable
,
:trackable
,
:validatable
<<<<<<<
HEAD
=======
validates
:email
validates
:encrypted_password
,
presence:
true
validates
:first_name
,
presence:
true
validates
:last_name
,
presence:
true
validates
:birthday
validates
:gender
>>>>>>>
eab438a60d774a5c3833f57eff50b31b57c6cd5c
end
app/models/vote.rb
View file @
c4ba16d8
...
...
@@ -2,5 +2,11 @@ class Vote < ActiveRecord::Base
belongs_to
:user
belongs_to
:candidate
<<<<<<<
HEAD
validates
:candidate
,
presence:
true
,
uniqueness:
true
=======
validates
:user_id
,
presence:
true
,
uniqueness:
true
validates
:candidate_id
,
presence:
true
,
uniqueness:
true
validates
:comments
>>>>>>>
eab438a60d774a5c3833f57eff50b31b57c6cd5c
end
app/views/candidates/edit.html.erb
View file @
c4ba16d8
<div
class =
"container"
>
<h1>
Edit Candidate
</h1>
<
<<<<<<
HEAD
=
======
>
>>>>>> eab438a60d774a5c3833f57eff50b31b57c6cd5c
<%=
render
'form'
%>
</div>
\ No newline at end of file
app/views/candidates/index.html.erb
View file @
c4ba16d8
<div
class =
"container"
>
<
<<<<<<
HEAD
<%
@candidates
.
group_by
(
&
:position
).
each
do
|
p
,
can
|
%>
<
h4
>
<%=
p
.
name
%>
</h4>
<table
class =
"table"
>
...
...
@@ -26,4 +27,59 @@
</table>
<%
end
%>
<%=
link_to
'New Candidate'
,
new_candidate_path
,
class:
"btn btn-primary"
%>
=======
<%#- <%= current_admin.email %>
<%
@candidates
.
group_by
(
&
:position
).
each
do
|
p
,
can
|
%>
<h4>
<%=
p
.
name
%>
</h4>
<table
class =
"table"
>
<thead>
<th>
First Name
</th>
<th>
Last Name
</th>
<th>
Nickname
</th>
<%
if
!
admin_signed_in?
%>
<th>
Votes
</th>
<%
end
%>
<%
if
admin_signed_in?
%>
<th>
Slogan
</th>
<%
end
%>
</thead>
<tbody>
<%
can
.
each
do
|
c
|
%>
<tr>
<td>
<%=
c
.
first_name
%>
</td>
<td>
<%=
c
.
last_name
%>
</td>
<td>
<%=
c
.
nickname
%>
</td>
<%
if
!
admin_signed_in?
%>
<td>
<%=
c
.
votes
.
count
%>
</td>
<%
end
%>
<%
if
admin_signed_in?
%>
<td>
<%=
c
.
slogan
%>
<td>
<%=
link_to
'Show'
,
show_candidates_path
(
c
),
class:
"btn btn-primary"
%>
</td>
<td>
<%=
link_to
'Edit'
,
edit_candidates_path
(
c
),
class:
"btn btn-success"
%>
</td>
<td>
<a
href=
"/candidates/delete?id=
<%=
c
.
id
%>
"
><button
class=
"btn btn-danger"
>
Delete
</button></a></td>
<%
end
%>
</tr>
<%
end
%>
</tbody>
</table>
<%
end
%>
<%
if
admin_signed_in?
%>
<%=
link_to
'New Candidate'
,
new_candidates_path
,
class:
"btn btn-primary"
%>
<%
end
%>
<%
if
user_signed_in?
%>
<%=
link_to
'Vote'
,
vote_candidates_path
,
class:
"btn btn-primary"
%>
<%
end
%>
>>>>>>> eab438a60d774a5c3833f57eff50b31b57c6cd5c
</div>
\ No newline at end of file
app/views/candidates/new.html.erb
View file @
c4ba16d8
<
<<<<<<
HEAD
<
div
class =
"container"
>
<h1>
New Candidate
</h1>
<%=
render
'form'
%>
</div>
\ No newline at end of file
</div>
=======
<h1>
New Candidate
</h1>
<!--
<%=
form_for
(
@candidate
)
do
|
u
|
%>
<%
if
@candidate
.
errors
.
any?
%>
<ul>
<%=
@candidate
.
errors
.
full_messages
.
each
do
|
message
|
%>
<li>
<%=
message
%>
</li>
<%
end
%>
</ul>
<%
end
%>
<p>
<%=
u
.
label
"First Name: "
%>
<%=
u
.
text_field
:first_name
%>
</p>
<p>
<%=
u
.
label
"Last Name: "
%>
<%=
u
.
text_field
:last_name
%>
</p>
<p>
<%=
u
.
label
"Nickname: "
%>
<%=
u
.
text_field
:nickname
%>
</p>
<p>
<%=
u
.
label
"Slogan"
%>
<%=
u
.
text_area
:slogan
%>
<%
if
@candidate
.
errors
.
messages
[
:slogan
].
any?
%>
<%
end
%>
</p>
<button class = "btn btn-success"> Create Candidate
<%
u
.
submit
%>
</button>
<br>
<br>
<%
end
%>
<%=
link_to
'Cancel'
,
candidates_path
,
class:
"btn btn-danger"
%>
-->
<%=
render
'form'
%>
>>>>>>> eab438a60d774a5c3833f57eff50b31b57c6cd5c
app/views/layouts/application.html.erb
View file @
c4ba16d8
...
...
@@ -16,7 +16,10 @@
<ul
class=
"nav navbar-nav"
>
<li>
<%=
link_to
'View Positions'
,
positions_path
%>
</a></li>
<
<<<<<<
HEAD
<
li
>
<%=
link_to
'View Candidates'
,
candidates_path
%>
</a></li>
=======
>>>>>>> eab438a60d774a5c3833f57eff50b31b57c6cd5c
</ul>
...
...
app/views/positions/_form.html.erb
View file @
c4ba16d8
<
<<<<<<
HEAD
<%=
simple_form_for
(
@position
)
do
|
p
|
%>
<%=
p
.
input
:name
%>
<%=
p
.
input
:number_of_winners
%>
...
...
@@ -5,3 +6,15 @@
<%=
link_to
'Cancel'
,
candidates_path
,
class:
"btn btn-danger"
%>
<%
end
%>
=======
<%=
simple_form_for
(
@position
)
do
|
p
|
%>
<%=
p
.
input
:name
%>
<%=
p
.
input
:number_of_winners
%>
<
button
class =
"btn btn-success"
>
Create new position
<%
p
.
submit
%>
</button>
<%
end
%>
<%=
link_to
'Cancel'
,
positions_path
,
class:
"btn btn-danger"
%>
>>>>>>> eab438a60d774a5c3833f57eff50b31b57c6cd5c
app/views/positions/edit.html.erb
View file @
c4ba16d8
<
<<<<<<
HEAD
<
div
class =
"container"
>
<h1>
Edit Position
</h1>
s
<%=
render
'form'
%>
</div>
\ No newline at end of file
</div>
=======
<h1>
Edit Position
</h1>
<%=
form_for
(
@position
,
url:
update_position_path
(
@position
))
do
|
p
|
%>
<p>
<%=
p
.
label
"Name"
%>
<%=
p
.
text_field
:name
%>
</p>
<p>
<%=
p
.
label
"Number of Winners"
%>
<%=
p
.
text_field
:number_of_winners
%>
</p>
<button
class =
"btn btn-success"
>
Edit position
<%
p
.
submit
%>
</button>
<%
end
%>
<%=
link_to
'Cancel'
,
positions_path
,
class:
"btn btn-danger"
%>
>>>>>>> eab438a60d774a5c3833f57eff50b31b57c6cd5c
app/views/positions/index.html.erb
View file @
c4ba16d8
<
<<<<<<
HEAD
<
div
class =
"container"
>
<h1>
List of Positions
</h1>
<table
class =
"table"
>
...
...
@@ -18,4 +19,28 @@
</tbody>
</table>
<%=
link_to
'Add new position'
,
new_position_path
,
class:
"btn btn-primary"
%>
</div>
\ No newline at end of file
</div>
=======
<h1>
List of Positions
</h1>
<table
class =
"table"
>
<thead>
<th>
Name
</th>
<th>
Number of Winners
</th>
</thead>
<tbody>
<%
@positions
.
each
do
|
c
|
%>
<tr>
<td>
<%=
c
.
name
%>
</td>
<td>
<%=
link_to
'Show'
,
show_position_path
(
c
)
%>
</td>
<td>
<%=
link_to
'Edit'
,
edit_position_path
(
c
)
%>
</td>
<td>
<%=
link_to
'Delete'
,
delete_position_path
(
c
)
%>
</td>
</tr>
<%
end
%>
</tbody>
</table>
<%=
link_to
'Add new position'
,
new_positions_path
,
class:
"btn btn-primary"
%>
>>>>>>> eab438a60d774a5c3833f57eff50b31b57c6cd5c
app/views/positions/new.html.erb
View file @
c4ba16d8
<
<<<<<<
HEAD
<
div
class =
"container"
>
<h1>
New Position
</h1>
<%=
render
'form'
%>
</div>
\ No newline at end of file
</div>
=======
<h1>
New Position
</h1>
<%=
render
"form"
%>
>>>>>>> eab438a60d774a5c3833f57eff50b31b57c6cd5c
app/views/positions/show.html.erb
View file @
c4ba16d8
<
<<<<<<
HEAD
<
div
class =
"container"
>
<h1>
Candidates for
<%=
@position
.
name
%>
</h1>
...
...
@@ -22,4 +23,32 @@
</tbody>
</table>
<%=
link_to
'Back'
,
positions_path
,
class:
"btn btn-primary"
%>
</div>
\ No newline at end of file
</div>
=======
bu
<h1>
Candidates for
<%=
@position
.
name
%>
</h1>
<table
class =
"table"
>
<thead>
<th>
First Name
</th>
<th>
Last Name
</th>
<th>
Nickname
</th>
<th>
Slogan
</th>
</thead>
<tbody>
<%
@position
.
candidate
.
each
do
|
c
|
%>
<tr>
<td>
<%=
c
.
first_name
%>
</td>
<td>
<%=
c
.
last_name
%>
</td>
<td>
<%=
c
.
nickname
%>
</td>
<td>
<%=
c
.
slogan
%>
</td>
</tr>
<%
end
%>
</tbody>
</table>
<%=
link_to
'Back'
,
positions_path
%>
>>>>>>> eab438a60d774a5c3833f57eff50b31b57c6cd5c
config/routes.rb
View file @
c4ba16d8
<<<<<<<
HEAD
Rails
.
application
.
routes
.
draw
do
resources
:candidates
resources
:positions
...
...
@@ -11,4 +12,45 @@ Rails.application.routes.draw do
devise_for
:users
devise_for
:admins
=======
Rails
.
application
.
routes
.
draw
do
devise_for
:users
devise_for
:admins
root
'candidates#index'
get
'/candidates'
,
to:
'candidates#index'
,
as: :candidates
get
'/candidates/new'
,
to:
'candidates#new'
,
as: :new_candidates
get
'/candidates/vote'
,
to:
'candidates#vote'
,
as: :vote_candidates
get
'candidates/edit/:id'
,
to:
'candidates#edit'
,
as: :edit_candidates
get
'/candidates/show/:id'
,
to:
'candidates#show'
,
as: :show_candidates
patch
'candidates/update/:id'
,
to:
'candidates#update'
,
as: :update_candidates
get
'/candidates/delete'
,
to:
'candidates#destroy'
,
as: :delete_candidates
post
'/candidates'
,
to:
'candidates#create'
,
as: :candidate
get
'positions'
,
to
:'positions#index'
,
as: :positions
get
'positions/new'
,
to
:'positions#new'
,
as: :new_positions
patch
'positions/update/:id'
,
to:
'positions#update'
,
as: :update_position
post
'positions'
,
to:
'positions#create'
,
as: :create_position
get
'positions/edit/:id'
,
to:
'positions#edit'
,
as: :edit_position
get
'positions/show/:id'
,
to:
'positions#show'
,
as: :show_position
get
'/positions/delete/:id'
,
to:
'positions#destroy'
,
as: :delete_position
>>>>>>>
eab438a60d774a5c3833f57eff50b31b57c6cd5c
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