projects_helper.rb 1.4 KB
Newer Older
R
randx 已提交
1 2 3 4
module ProjectsHelper
  def grouper_project_members(project)
    @project.users_projects.sort_by(&:project_access).reverse.group_by(&:project_access)
  end
D
Dmitriy Zaporozhets 已提交
5 6 7 8

  def remove_from_team_message(project, member)
    "You are going to remove #{member.user_name} from #{project.name}. Are you sure?"
  end
9 10

  def link_to_project project
11 12 13 14 15 16 17 18 19 20
    link_to project do
      title = content_tag(:strong, project.name)

      if project.namespace
        namespace = content_tag(:span, "#{project.namespace.human_name} / ", class: 'tiny')
        title = namespace + title
      end

      title
    end
21
  end
R
randx 已提交
22

23 24 25 26
  def link_to_member(project, author, opts = {})
    default_opts = { avatar: true }
    opts = default_opts.merge(opts)

27 28
    return "(deleted)" unless author

29 30
    author_html =  ""

31
    # Build avatar image tag
32
    author_html << image_tag(gravatar_icon(author.try(:email)), width: 16, class: "lil_av") if opts[:avatar]
33

34
    # Build name span tag
35
    author_html << content_tag(:span, sanitize(author.name), class: 'author')
36

37
    author_html = author_html.html_safe
38 39 40

    tm = project.team_member_by_id(author)

41 42 43 44
    if tm
      link_to author_html, project_team_member_path(project, tm), class: "author_link"
    else
      author_html
45
    end.html_safe
46 47
  end

R
randx 已提交
48 49 50
  def tm_path team_member
    project_team_member_path(@project, team_member)
  end
51 52 53 54 55 56 57 58

  def project_title project
    if project.group
      project.name_with_namespace
    else
      project.name
    end
  end
R
randx 已提交
59
end