Mercurial > hg > soundsoftware-site
changeset 1006:4ffe9098c16c browsing
Busy-projects partial, etc
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Fri, 09 Nov 2012 17:41:04 +0000 |
parents | 85123e5bc883 |
children | 3e52bc15dd67 |
files | app/views/activities/_busy.html.erb app/views/projects/_latest.html.erb app/views/welcome/index.html.erb config/locales/en.yml |
diffstat | 4 files changed, 86 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/views/activities/_busy.html.erb Fri Nov 09 17:41:04 2012 +0000 @@ -0,0 +1,58 @@ +<% events = @events_by_day %> +<% max = 5 %> +<% if (events.nil?) + activity = Redmine::Activity::Fetcher.new(User.current) + events = activity.events(Date.today - 14, Date.today + 1) + end +%> + +<% if events.empty? %> + +<% else %> + + <ul> + + <% + # Transform events list into hash from project id to number of + # occurrences of project in list (there is surely a tidier way + # to do this, e.g. chunk() in Ruby 1.9 but not in 1.8) + phash = events.map { |e| e.project }.sort.group_by { |p| p.id } + phash = phash.merge(phash) { |k,v| v.length } + threshold = phash.values.sort.last(max).first + busy = phash.keys.select { |k| phash[k] >= threshold }.sample(max) + + for id in busy + project = Project.find(id) + %> + + <li class="busy"> + <span class="title"> + <% if !project.root? %> + <% project.ancestors.each do |p| %> + <%= h(p) %> » + <% end %> + <% end %> + <%= link_to_project project %> + </span> + <% if !project.is_public? %> + <span class="private"><%= l(:field_is_private) %></span> + <% end %> + <span class='managers'> + <% + u = project.users_by_role + if ! u.empty? %> + (<%= + mgmt_roles = u.keys.select{ |r| r.allowed_to?(:edit_project) } + managers = mgmt_roles.map{ |r| u[r] }.flatten.sort.uniq + managers.map{ |m| m.name }.join(', ') + %>)<% + end + %> + </span> + + <%= render_project_short_description project %> + </li> + + <% end %> + </ul> +<% end %>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/views/projects/_latest.html.erb Fri Nov 09 17:41:04 2012 +0000 @@ -0,0 +1,21 @@ + <ul> + <% for project in @projects %> + <% @project = project %> + <li class="latest"> + <span class="title"> + <% if !project.root? %> + <% project.ancestors.each do |p| %> + <%= h(p) %> » + <% end %> + <% end %> + <%= link_to_project project %> + </span> + <% if !project.is_public? %> + <span class="private"><%= l(:field_is_private) %></span> + <% end %> + <span class="time"><%= format_time(project.created_on)%></span> + <%= render_project_short_description project %> + </li> + <% end %> + <% @project = nil %> + </ul>
--- a/app/views/welcome/index.html.erb Fri Nov 09 16:33:06 2012 +0000 +++ b/app/views/welcome/index.html.erb Fri Nov 09 17:41:04 2012 +0000 @@ -31,6 +31,11 @@ <%= render :partial => 'projects/tagcloud' %> <%= link_to l(:label_projects_more), :controller => 'projects' %> </div> + <div class="projects box"> + <h3><%=l(:label_projects_busy)%></h3> + <%= render :partial => 'activities/busy' %> + <%= link_to l(:label_projects_more), :controller => 'projects' %> + </div> <% end %> <%= call_hook(:view_welcome_index_right, :projects => @projects) %> </div>
--- a/config/locales/en.yml Fri Nov 09 16:33:06 2012 +0000 +++ b/config/locales/en.yml Fri Nov 09 17:41:04 2012 +0000 @@ -494,7 +494,8 @@ label_project_all: All Projects label_project_latest: Latest projects label_projects_more: More projects - label_project_tags_all: Project tags + label_project_tags_all: Tags for projects + label_projects_busy: Busy projects label_managers: Managed by label_issue: Issue label_issue_new: New issue