-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Balazs Kutil
committed
Apr 8, 2015
1 parent
203c075
commit e401a21
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
class ProjectDecorator < Draper::Decorator | ||
delegate_all | ||
|
||
def state_name | ||
if ["idea", "invention"].include?(object.aasm_state) | ||
"an #{object.aasm_state}" | ||
else | ||
"a #{object.aasm_state}" | ||
end | ||
end | ||
|
||
def updated_at | ||
"Last updated #{h.time_ago_in_words(object.updated_at)} ago." | ||
end | ||
|
||
def kudos | ||
if object.kudos.length > 0 | ||
"Captured #{h.pluralize(object.kudos.length, "hackers heart.", "hacker hearts.")}" | ||
else | ||
"No love." | ||
end | ||
end | ||
|
||
def grab_it_link | ||
if object.users.empty? | ||
"No hacker. How about you #{h.link_to('grab it!', h.join_project_path(object), :method => :post)}".html_safe | ||
end | ||
end | ||
|
||
def like_button | ||
dislike = "display: none;" unless object.kudos.include?(h.current_user) | ||
like = "display: none;" if object.kudos.include?(h.current_user) | ||
|
||
dislike_opts = {:title=>'Dislike this project?', :class=> "btn btn-default btn-xs", :id => "dislike-#{object.id}", :style => "#{dislike}", :remote=>true} | ||
like_opts = {:title=>'Like this project', :class=> "btn btn-default btn-xs", :id => "like-#{object.id}", :style => "#{like}", :remote => true} | ||
|
||
h.link_to(h.dislike_project_path(object), dislike_opts) { h.content_tag(:i, "", :class => 'fa fa-heart', :style => "color: #73ba25;") }.html_safe + | ||
h.link_to(h.like_project_path(object), like_opts) { h.content_tag(:i, "", :class => 'fa fa-heart-o') }.html_safe | ||
end | ||
end |