socialforge/app/helpers/applied_project_helper.rb

22 lines
543 B
Ruby

module AppliedProjectHelper
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)
if applied
appliedid = applied.id
end
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
end
end