|
|
|
@ -30,7 +30,7 @@ module WatchersHelper
|
|
|
|
|
objects = Array.wrap(objects)
|
|
|
|
|
|
|
|
|
|
watched = objects.any? {|object| object.watched_by?(user)}
|
|
|
|
|
@watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or objects.first.instance_of?(Contest) or (objects.first.instance_of?(Bid)))
|
|
|
|
|
@watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or objects.first.instance_of?(Contest) or (objects.first.instance_of?(Bid)))
|
|
|
|
|
css = @watch_flag ? ([watcher_css(objects), watched ? 'icon ' : 'icon '].join(' ') << options[0].to_s) :
|
|
|
|
|
([watcher_css(objects), watched ? 'icon icon-fav ' : 'icon icon-fav-off '].join(' ') << options[0].to_s)
|
|
|
|
|
|
|
|
|
@ -188,22 +188,30 @@ module WatchersHelper
|
|
|
|
|
end.join.html_safe
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def applied_css(project)
|
|
|
|
|
id = project.id
|
|
|
|
|
"#{project.class.to_s.underscore}-#{id}-applied"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def applied_link(project, user, options=[])
|
|
|
|
|
return '' unless user && user.logged?
|
|
|
|
|
applied = project.applied_projects.find_by_user_id(user.id)
|
|
|
|
|
text = applied ? l(:label_unapply_project) : l(:label_apply_project)
|
|
|
|
|
|
|
|
|
|
@applied_flag = project.instance_of?(Project)
|
|
|
|
|
css = @applied_flag ? ([applied_css(project), applied ? 'icon ' : 'icon '].join(' ') << options[0].to_s) :
|
|
|
|
|
([applied_css(project), applied ? 'icon icon-applied ' : 'icon icon-applied-off '].join(' ') << options[0].to_s)
|
|
|
|
|
if applied
|
|
|
|
|
appliedid = applied.id
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
url = appliedproject_path(
|
|
|
|
|
url = appliedproject_path(
|
|
|
|
|
:id=>appliedid,
|
|
|
|
|
:user_id => user.id,
|
|
|
|
|
:project_id => project.id
|
|
|
|
|
)
|
|
|
|
|
method = applied ? 'delete' : 'post'
|
|
|
|
|
|
|
|
|
|
link_to text, url, :remote => true, :method => method
|
|
|
|
|
link_to text, url, :remote => true, :method => method ,:class=>css
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|