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
720332d7
Commit
720332d7
authored
Jul 19, 2016
by
royce-matthew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added images
parent
a2dbb107
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
31 additions
and
11 deletions
+31
-11
style.css
app/assets/stylesheets/style.css
+5
-0
candidate.rb
app/models/candidate.rb
+8
-0
user.rb
app/models/user.rb
+3
-4
_form.html.erb
app/views/admin/candidates/_form.html.erb
+1
-0
index.html.erb
app/views/pages/index.html.erb
+3
-3
index.html.erb
app/views/voting/votes/index.html.erb
+4
-3
20160719070050_adding_photo_link_to_candidate.rb
db/migrate/20160719070050_adding_photo_link_to_candidate.rb
+5
-0
schema.rb
db/schema.rb
+2
-1
No files found.
app/assets/stylesheets/style.css
View file @
720332d7
...
@@ -38,3 +38,8 @@
...
@@ -38,3 +38,8 @@
{
{
float
:
right
;
float
:
right
;
}
}
.candidate-image
{
border-radius
:
50%
;
border
:
1px
#e7e7e7
solid
;
}
\ No newline at end of file
app/models/candidate.rb
View file @
720332d7
...
@@ -12,4 +12,12 @@ class Candidate < ActiveRecord::Base
...
@@ -12,4 +12,12 @@ class Candidate < ActiveRecord::Base
def
full_name
def
full_name
"
#{
self
.
first_name
}
#{
self
.
last_name
}
"
"
#{
self
.
first_name
}
#{
self
.
last_name
}
"
end
end
def
image
if
self
.
image_link
==
nil
"https://65.media.tumblr.com/avatar_19642255c98d_128.png"
else
self
.
image_link
end
end
end
end
\ No newline at end of file
app/models/user.rb
View file @
720332d7
...
@@ -6,9 +6,8 @@ class User < ActiveRecord::Base
...
@@ -6,9 +6,8 @@ class User < ActiveRecord::Base
:recoverable
,
:rememberable
,
:trackable
,
:validatable
:recoverable
,
:rememberable
,
:trackable
,
:validatable
has_many
:votes
has_many
:votes
def
list_of_positions
def
full_name
x
=
"hello"
"
#{
self
.
first_name
}
#{
self
.
last_name
}
"
end
end
end
end
app/views/admin/candidates/_form.html.erb
View file @
720332d7
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
<%=
f
.
association
:position
,
label_method: :name
,
value_method: :id
%>
<%=
f
.
association
:position
,
label_method: :name
,
value_method: :id
%>
<%=
f
.
input
:first_name
%>
<%=
f
.
input
:first_name
%>
<%=
f
.
input
:last_name
%>
<%=
f
.
input
:last_name
%>
<%=
f
.
input
:image_link
%>
<%=
f
.
input
:slogan
%>
<%=
f
.
input
:slogan
%>
<%=
f
.
submit
%>
<%=
f
.
submit
%>
<%
end
%>
<%
end
%>
app/views/pages/index.html.erb
View file @
720332d7
...
@@ -3,15 +3,15 @@
...
@@ -3,15 +3,15 @@
<%
@positions
.
each
do
|
p
|
%>
<%
@positions
.
each
do
|
p
|
%>
<div
style=
"display:inline-block; padding:20px"
>
<div
style=
"display:inline-block; padding:20px"
>
<h4>
<%=
p
.
name
%>
</h4>
<h4>
<%=
p
.
name
%>
</h4>
<table
style=
"width:
300px
;"
>
<table
style=
"width:
100%
;"
>
<thead><td>
Name
</td><td>
Slogan
</td><td>
Votes
</td></thead>
<thead><td>
</td><td>
Name
</td><td>
Slogan
</td><td>
Votes
</td><td>
</td></thead>
<%
total
=
0
%>
<%
total
=
0
%>
<%
p
.
candidates
.
each
do
|
c
|
%>
<%
p
.
candidates
.
each
do
|
c
|
%>
<%
total
=
total
+
c
.
votes
.
count
%>
<%
total
=
total
+
c
.
votes
.
count
%>
<%
end
%>
<%
end
%>
<%
p
.
candidates
.
each
do
|
c
|
%>
<%
p
.
candidates
.
each
do
|
c
|
%>
<tr><td>
<
%=
link_to
c
.
full_name
,
admin_candidate_path
(
c
.
id
),
{
:style
=>
"font-size:15 px;"
}
%>
</td><td
>
<%=
c
.
slogan
%>
</td><td>
<%=
c
.
votes
.
count
%>
</td>
<tr><td><
img
class=
"candidate-image"
style=
"background: url(
<%=
c
.
image
%>
); background-size:cover; background-position: 50% 50%; height:64px; width:64px; "
width=
"64px"
height=
"64px;"
></td><td
style=
"min-width: 250px;"
>
<%=
link_to
c
.
full_name
,
admin_candidate_path
(
c
.
id
),
{
:style
=>
"font-size:15 px;"
}
%>
</td><td
style=
"min-width: 300px;"
>
<%=
c
.
slogan
%>
</td><td>
<%=
c
.
votes
.
count
%>
</td>
<td>
<progress
value=
"
<%=
c
.
votes
.
count
%>
"
max=
"
<%=
total
%>
"
></td>
<td>
<progress
value=
"
<%=
c
.
votes
.
count
%>
"
max=
"
<%=
total
%>
"
></td>
</tr>
</tr>
<%
end
%>
<%
end
%>
...
...
app/views/voting/votes/index.html.erb
View file @
720332d7
...
@@ -5,17 +5,18 @@
...
@@ -5,17 +5,18 @@
<%=
link_to
"Logout"
,
destroy_user_session_path
,
method: :delete
%>
<%=
link_to
"Logout"
,
destroy_user_session_path
,
method: :delete
%>
-->
-->
<br>
<br>
<td>
Hello
<%=
current_user
.
email
%>
</td>
<td>
Hello
<%=
current_user
.
full_name
%>
</td>
<br>
<br>
<br>
<br>
<ul>
<ul>
<%
@positions
.
each
do
|
p
|
%>
<%
@positions
.
each
do
|
p
|
%>
<li>
has user already voted for
<%=
p
.
name
%>
?
<br>
<li>
<%=
p
.
name
%>
<br>
<%
voted_for
=
false
%>
<%
voted_for
=
false
%>
<%
p
.
candidates
.
each
do
|
c
|
%>
<%
p
.
candidates
.
each
do
|
c
|
%>
<%
c
.
votes
.
each
do
|
v
|
%>
<%
c
.
votes
.
each
do
|
v
|
%>
<%
if
v
.
user_id
==
current_user
.
id
%>
<%
if
v
.
user_id
==
current_user
.
id
%>
You have already voted for
<%=
v
.
candidate
.
full_name
%>
<%
voted_for
=
true
%>
<%
voted_for
=
true
%>
<%
end
%>
<%
end
%>
<%
end
%>
<%
end
%>
...
@@ -25,7 +26,7 @@
...
@@ -25,7 +26,7 @@
<%
if
!
voted_for
%>
<%
if
!
voted_for
%>
<%=
link_to
"Vote for a
#{
p
.
name
}
"
,
"/voting/new/
#{
p
.
id
}
"
%>
<%=
link_to
"Vote for a
#{
p
.
name
}
"
,
"/voting/new/
#{
p
.
id
}
"
%>
<%
else
%>
<%
else
%>
You have already Voted for a
<%=
p
.
name
%>
<%
end
%>
<%
end
%>
</li>
</li>
...
...
db/migrate/20160719070050_adding_photo_link_to_candidate.rb
0 → 100644
View file @
720332d7
class
AddingPhotoLinkToCandidate
<
ActiveRecord
::
Migration
[
5.0
]
def
change
add_column
:candidates
,
:image_link
,
:string
end
end
db/schema.rb
View file @
720332d7
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2016071
8145025
)
do
ActiveRecord
::
Schema
.
define
(
version:
2016071
9070050
)
do
create_table
"candidates"
,
force: :cascade
do
|
t
|
create_table
"candidates"
,
force: :cascade
do
|
t
|
t
.
string
"first_name"
t
.
string
"first_name"
...
@@ -20,6 +20,7 @@ ActiveRecord::Schema.define(version: 20160718145025) do
...
@@ -20,6 +20,7 @@ ActiveRecord::Schema.define(version: 20160718145025) do
t
.
integer
"position_id"
t
.
integer
"position_id"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
string
"image_link"
end
end
create_table
"positions"
,
force: :cascade
do
|
t
|
create_table
"positions"
,
force: :cascade
do
|
t
|
...
...
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