module ProjectsHelper include BlueclothHelper def get_project_audience_suffix (project) project.audience == :members_only ? " (Private)" : "" end #FIXME move to partial def render_right_project_extrainfo # removed tags, website, bugtracker and mailing list from Gitorious box (consider removing mailing list too, or make these all option in setup) out = "" out << "" out << %Q{} out << %Q{} out << %Q{} out << %Q{} out << %Q{} out << %Q{} out << %Q{} out << %Q{} out << "
Details
Created:#{format_datetime_ddmmyyhhmm(@project.created_at)}
By:#{link_to(h(@project.user.fullname), user_path(@project.user))}
Status:#{@project.status.to_s.capitalize}
Life Cycle:#{format_life_cycle(@project.life_cycle)}
Audience:#{@project.audience.to_s.capitalize}
OS:#{@project.os.to_s.capitalize}
Platform:#{@project.platform.to_s.capitalize}
License:#{h(@project.license)}
" out end def render_right_project_members out = "" members = Member.find_by_project(@project.id) unless members.empty? out << "" out << "" for member in members #TODO only display admin/modify members out << %Q{} if member.accesslevel != :user end out << "
Members
#{link_to_profile(member.user)} (#{format_member_accesslevel(member.accesslevel)})
" end out end def render_right_popular_projects out = "" projects = Project.find_popular_projects(current_user) unless projects.empty? out << "" out << "" for project in projects #TODO only display admin/modify members out << %Q{} end out << "
Popular Projects
#{link_to(project.title, project_path(project))}
" end out end def project_tab (active_tab, tab) title, suffix = Project.tab_settings(tab, @project.wiki_slug) path = %Q{/projects/#{@project.slug}#{suffix}} active_tab == tab ? %Q{
  • #{link_to(title, path, :class => "active")}
  • } : %Q{
  • #{link_to(title, path)}
  • } end def render_project_tabs (active_tab) out = "" out << "" out end def breadcrumb_repos_tab(subtab) subtab == PRJ_TAB_SUBTAB_NONE ? out = "" : out = breadcrumb_repositories case subtab when PRJ_TAB_GIT_LOGS out << breadcrumb_repository when PRJ_TAB_GIT_COMMIT out << breadcrumb_repository out << breadcrumb_repos_logs when PRJ_TAB_GIT_TREE out << breadcrumb_repository when PRJ_TAB_GIT_MERGEREQUESTS end out end # #FIXME I don't understand why this doesn't cause an error when logged out #FIXME also the membership is being checked everytime another query in Project is called, it's not very optimal #FIXME also we need to get the Accesslevel for the member, some actions are restricted to admins (actually is accesslevel redundant # as we know if it's a user/member and if a user is an admin seperately - or is a project admin different than a site admin? def render_right_column_project (tab, subtab) out = "" case tab when PRJ_TAB_SUMMARY out << actionbox_complex(:allow_shortcuts => true) out << render_right_project_extrainfo out << render_right_project_roadmap out << render_right_project_members when PRJ_TAB_GIT case subtab when PRJ_TAB_SUBTAB_NONE out << actionbox_complex(:allow_shortcuts => true, :clone_mainline => true) when PRJ_TAB_GIT_SUMMARY out << render(:partial => "repositories/ac_right_actionbox_repos_summary") when PRJ_TAB_GIT_LOGS out << actionbox_basic(:allow_shortcuts => true) out << render(:partial => "repositories/ac_right_branches") when PRJ_TAB_GIT_COMMIT out << actionbox_basic(:allow_shortcuts => true) out << render(:partial => "commits/ac_right_diff_mode_selector") when PRJ_TAB_GIT_TREE out << actionbox_basic(:allow_shortcuts => true) out << render(:partial => "trees/ac_right_branches") when PRJ_TAB_GIT_MERGEREQUESTS out << actionbox_basic(:allow_shortcuts => true) end when PRJ_TAB_TEAM case subtab when PRJ_TAB_SUBTAB_NONE out << actionbox_complex(:allow_shortcuts => true, :new_member => true, :list_members => true) out << render(:partial => "messages/ac_right_actionbox_post_message") if @is_member out << render_right_project_members when PRJ_TAB_TEAM_NEW when PRJ_TAB_TEAM_LIST end when PRJ_TAB_TICKETS case subtab when PRJ_TAB_SUBTAB_NONE out << actionbox_complex(:allow_shortcuts => true, :new_ticket => true, :manage_milestones => true, :manage_components => true) out << render(:partial => "ac_right_ticket_filter") out << render_right_project_roadmap when PRJ_TAB_TICKETS_SHOW out << actionbox_complex(:allow_shortcuts => true, :manage_tickets => true, :edit_ticket => true, :close_ticket => true) when PRJ_TAB_TICKETS_NEW, PRJ_TAB_TICKETS_EDIT out << actionbox_complex(:allow_shortcuts => true, :manage_tickets => true) when PRJ_TAB_TICKETS_MILESTONES_LIST out << actionbox_complex(:allow_shortcuts => true, :new_milestone => true, :manage_tickets => true) when PRJ_TAB_TICKETS_MILESTONES_NEW, PRJ_TAB_TICKETS_MILESTONES_EDIT out << actionbox_complex(:allow_shortcuts => true, :manage_tickets => true, :manage_milestones => true) end when PRJ_TAB_WIKI case subtab when PRJ_TAB_WIKI_EDIT, PRJ_TAB_WIKI_NEW out << actionbox_basic(:allow_shortcuts => true) when PRJ_TAB_WIKI_LIST out << actionbox_complex(:allow_shortcuts => true, :new_project_wiki => true) else out << actionbox_complex(:allow_shortcuts => true, :edit_project_wiki => true, :new_project_wiki => true, :manage_project_wikis => true) end when PRJ_TAB_ARTICLES case subtab when PRJ_TAB_ARTICLES_EDIT, PRJ_TAB_ARTICLES_NEW out << actionbox_basic(:allow_shortcuts => true) else out << actionbox_complex(:allow_shortcuts => true, :new_article => true) end when PRJ_TAB_FORUM out << actionbox_basic(:allow_shortcuts => true) when PRJ_TAB_LOG out << actionbox_basic(:allow_shortcuts => true) when PRJ_TAB_CONFIG out << actionbox_basic(:allow_shortcuts => true) end out end def render_right_project_roadmap #get all milestones for a project #order by date desc #if there is a version linked, show that next to milestone out = "" out << "" out << "" @milestones = Milestone.roadmap(@project.id, current_user) unless @milestones.empty? for milestone in @milestones # milestone title out << "" end end out << "
    Roadmap
    " out << format_date_ddbbyy(milestone.due_date) out << ": " << link_to(milestone.name, project_tickets_path(@project.slug)) << " (" << milestone.status.to_s.capitalize << ")" # milestone progress bar out << "" out << "" out << "" out << "" out << "" out << "
    " out << "
    " out end #TODO move to model def format_life_cycle (ls) case ls when :pre_alpha "Pre-Alpha" when :mature_frozen "Mature Frozen" else ls.to_s.capitalize end end #TODO move to model def format_member_accesslevel (al) case al when :readonly "read only" else al.to_s end end end