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
Hide 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
...
...
@@ -37,4 +37,9 @@
.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
def
full_name
"
#{
self
.
first_name
}
#{
self
.
last_name
}
"
end
def
image
if
self
.
image_link
==
nil
"https://65.media.tumblr.com/avatar_19642255c98d_128.png"
else
self
.
image_link
end
end
end
\ No newline at end of file
app/models/user.rb
View file @
720332d7
...
...
@@ -6,9 +6,8 @@ class User < ActiveRecord::Base
:recoverable
,
:rememberable
,
:trackable
,
:validatable
has_many
:votes
def
list_of_positions
x
=
"hello"
end
def
full_name
"
#{
self
.
first_name
}
#{
self
.
last_name
}
"
end
end
app/views/admin/candidates/_form.html.erb
View file @
720332d7
...
...
@@ -4,6 +4,7 @@
<%=
f
.
association
:position
,
label_method: :name
,
value_method: :id
%>
<%=
f
.
input
:first_name
%>
<%=
f
.
input
:last_name
%>
<%=
f
.
input
:image_link
%>
<%=
f
.
input
:slogan
%>
<%=
f
.
submit
%>
<%
end
%>
app/views/pages/index.html.erb
View file @
720332d7
...
...
@@ -3,15 +3,15 @@
<%
@positions
.
each
do
|
p
|
%>
<div
style=
"display:inline-block; padding:20px"
>
<h4>
<%=
p
.
name
%>
</h4>
<table
style=
"width:
300px
;"
>
<thead><td>
Name
</td><td>
Slogan
</td><td>
Votes
</td></thead>
<table
style=
"width:
100%
;"
>
<thead><td>
</td><td>
Name
</td><td>
Slogan
</td><td>
Votes
</td><td>
</td></thead>
<%
total
=
0
%>
<%
p
.
candidates
.
each
do
|
c
|
%>
<%
total
=
total
+
c
.
votes
.
count
%>
<%
end
%>
<%
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>
</tr>
<%
end
%>
...
...
app/views/voting/votes/index.html.erb
View file @
720332d7
...
...
@@ -5,17 +5,18 @@
<%=
link_to
"Logout"
,
destroy_user_session_path
,
method: :delete
%>
-->
<br>
<td>
Hello
<%=
current_user
.
email
%>
</td>
<td>
Hello
<%=
current_user
.
full_name
%>
</td>
<br>
<br>
<ul>
<%
@positions
.
each
do
|
p
|
%>
<li>
has user already voted for
<%=
p
.
name
%>
?
<br>
<li>
<%=
p
.
name
%>
<br>
<%
voted_for
=
false
%>
<%
p
.
candidates
.
each
do
|
c
|
%>
<%
c
.
votes
.
each
do
|
v
|
%>
<%
if
v
.
user_id
==
current_user
.
id
%>
You have already voted for
<%=
v
.
candidate
.
full_name
%>
<%
voted_for
=
true
%>
<%
end
%>
<%
end
%>
...
...
@@ -25,7 +26,7 @@
<%
if
!
voted_for
%>
<%=
link_to
"Vote for a
#{
p
.
name
}
"
,
"/voting/new/
#{
p
.
id
}
"
%>
<%
else
%>
You have already Voted for a
<%=
p
.
name
%>
<%
end
%>
</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 @@
#
# 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
|
t
.
string
"first_name"
...
...
@@ -20,6 +20,7 @@ ActiveRecord::Schema.define(version: 20160718145025) do
t
.
integer
"position_id"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
string
"image_link"
end
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