rosa-build/app/helpers/projects_helper.rb

54 lines
1.6 KiB
Ruby
Raw Normal View History

2012-01-30 20:39:34 +00:00
# -*- encoding : utf-8 -*-
2011-03-10 11:35:46 +00:00
module ProjectsHelper
def options_for_filters(all_projects, groups, owners)
(groups + owners).map do |o|
class_name = o.class.name
{
:id => "#{class_name.downcase}-#{o.id}",
:color => '464646',
:selected => false,
:check_box_name => class_name.downcase.pluralize,
:check_box_value => o.id,
:name => content_tag(:div, content_tag(:span, o.uname, :class => class_name.downcase)),
:uname => o.uname, # only for sorting
:count => all_projects.where(:owner_id => o, :owner_type => class_name).count
}
end.sort_by{ |f| f[:uname] }
end
2011-11-22 18:58:23 +00:00
def git_repo_url(name)
if current_user
"#{request.protocol}#{current_user.uname}@#{request.host_with_port}/#{name}.git"
else
"#{request.protocol}#{request.host_with_port}/#{name}.git"
end
end
def options_for_collaborators_roles_select
options_for_select(
Relation::ROLES.collect { |role|
[t("layout.collaborators.role_names.#{ role }"), role]
}
)
end
def visibility_icon(visibility)
visibility == 'open' ? 'unlock.png' : 'lock.png'
end
def participant_class(alone_member, project)
c = alone_member ? 'user' : 'group'
c = 'user_owner' if project.owner == current_user
c = 'group_owner' if project.owner.in? current_user.groups
return c
end
def alone_member?(project)
Relation.by_target(project).by_actor(current_user).size > 0
end
def participant_path(participant)
participant.kind_of?(User) ? user_path(participant) : group_path(participant)
end
2011-03-10 11:35:46 +00:00
end