Mercurial > hg > soundsoftware-site
changeset 1009:066b55d7c053 browsing
Add busy institutions list
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Mon, 12 Nov 2012 13:34:32 +0000 |
parents | 8196ed891e54 |
children | 76a677c96bce |
files | app/controllers/activities_controller.rb app/controllers/projects_controller.rb app/views/activities/_busy.html.erb app/views/activities/_busy_institution.html.erb app/views/activities/index.html.erb app/views/projects/browse.html.erb app/views/projects/explore.html.erb app/views/welcome/index.html.erb config/locales/en.yml config/routes.rb |
diffstat | 10 files changed, 95 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/app/controllers/activities_controller.rb Mon Nov 12 13:34:21 2012 +0000 +++ b/app/controllers/activities_controller.rb Mon Nov 12 13:34:32 2012 +0000 @@ -40,7 +40,20 @@ events = @activity.events(@date_from, @date_to) - if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, events.first, User.current, current_language]) + @institution_name = params[:institution] + if !@institution_name.blank? + events = events.select do |e| + e.respond_to?(:event_author) and e.event_author and + e.event_author.ssamr_user_detail.institution_name == @institution_name + end + if events.empty? + # We don't want to dump into the output any arbitrary string + # from the URL that has no matching events + @institution_name = "" + end + end + + if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, @institution_name, events.first, User.current, current_language]) respond_to do |format| format.html { @events_by_day = events.group_by(&:event_date)
--- a/app/controllers/projects_controller.rb Mon Nov 12 13:34:21 2012 +0000 +++ b/app/controllers/projects_controller.rb Mon Nov 12 13:34:32 2012 +0000 @@ -20,8 +20,8 @@ menu_item :roadmap, :only => :roadmap menu_item :settings, :only => :settings - before_filter :find_project, :except => [ :index, :list, :browse, :new, :create, :copy ] - before_filter :authorize, :except => [ :index, :list, :browse, :new, :create, :copy, :archive, :unarchive, :destroy] + before_filter :find_project, :except => [ :index, :list, :explore, :new, :create, :copy ] + before_filter :authorize, :except => [ :index, :list, :explore, :new, :create, :copy, :archive, :unarchive, :destroy] before_filter :authorize_global, :only => [:new, :create] before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ] accept_rss_auth :index @@ -76,12 +76,12 @@ end end - # A different view of projects using browse boxes - def browse + # A different view of projects using explore boxes + def explore respond_to do |format| format.html { @projects = Project.visible - render :template => 'projects/browse.html.erb', :layout => !request.xhr? + render :template => 'projects/explore.html.erb', :layout => !request.xhr? } end end
--- a/app/views/activities/_busy.html.erb Mon Nov 12 13:34:21 2012 +0000 +++ b/app/views/activities/_busy.html.erb Mon Nov 12 13:34:32 2012 +0000 @@ -16,7 +16,7 @@ # 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 = events.map { |e| e.project unless !e.respond_to?(: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)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/views/activities/_busy_institution.html.erb Mon Nov 12 13:34:32 2012 +0000 @@ -0,0 +1,34 @@ +<% 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> + + <% + authors = events.map { |e| e.event_author unless !e.respond_to?(:event_author) }.compact + institutions = authors.map { |a| a.ssamr_user_detail.institution_name } + insthash = institutions.compact.sort.group_by { |i| i } + insthash = insthash.merge(insthash) { |k,v| v.length } + threshold = insthash.values.sort.last(max).first + busy = insthash.keys.select { |k| insthash[k] >= threshold }.sample(max) + + for institution in busy + %> + + <li class="busy"> + <span class="title"> + <%= link_to h(institution), { :controller => 'activities', :institution => institution } %> + </span> + </li> + + <% end %> + </ul> +<% end %>
--- a/app/views/activities/index.html.erb Mon Nov 12 13:34:21 2012 +0000 +++ b/app/views/activities/index.html.erb Mon Nov 12 13:34:32 2012 +0000 @@ -1,4 +1,14 @@ -<h2><%= @author.nil? ? l(:label_activity) : l(:label_user_activity, link_to_user(@author)) %></h2> +<h2><%= + if @author.nil? + if @institution_name.blank? + l(:label_activity) + else + l(:label_institution_activity, h(@institution_name)) + end + else + l(:label_user_activity, link_to_user(@author)) + end + %></h2> <p class="subtitle"><%= l(:label_date_from_to, :start => format_date(@date_to - @days), :end => format_date(@date_to-1)) %></p> <div id="activity">
--- a/app/views/projects/browse.html.erb Mon Nov 12 13:34:21 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ - -<h2><%= l(:label_browse) %></h2> - -<div class="splitcontentleft"> - <div class="projects box"> - <h3><%=l(:label_project_latest)%></h3> - <%= render :partial => 'projects/latest' %> - <%= link_to l(:label_projects_more), :controller => 'projects' %> - </div> -</div> -<div class="splitcontentleft"> - <div class="projects box"> - <h3><%=l(:label_project_tags_all)%></h3> - <%= 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> -</div>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/views/projects/explore.html.erb Mon Nov 12 13:34:32 2012 +0000 @@ -0,0 +1,27 @@ + +<h2><%= l(:label_browse) %></h2> + +<div class="splitcontentleft"> + <div class="projects box"> + <h3><%=l(:label_project_latest)%></h3> + <%= render :partial => 'projects/latest' %> + <%= link_to l(:label_projects_more), :controller => 'projects' %> + </div> +</div> +<div class="splitcontentleft"> + <div class="projects box"> + <h3><%=l(:label_project_tags_all)%></h3> + <%= 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> + <div class="projects box"> + <h3><%=l(:label_institutions_busy)%></h3> + <%= render :partial => 'activities/busy_institution' %> + <%= link_to l(:label_projects_more), :controller => 'projects' %> + </div> +</div>
--- a/app/views/welcome/index.html.erb Mon Nov 12 13:34:21 2012 +0000 +++ b/app/views/welcome/index.html.erb Mon Nov 12 13:34:32 2012 +0000 @@ -25,16 +25,6 @@ <%= render :partial => 'projects/latest' %> <%= link_to l(:label_projects_more), :controller => 'projects' %> </div> - <div class="projects box"> - <h3><%=l(:label_project_tags_all)%></h3> - <%= 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> <%= call_hook(:view_welcome_index_right, :projects => @projects) %> </div>
--- a/config/locales/en.yml Mon Nov 12 13:34:21 2012 +0000 +++ b/config/locales/en.yml Mon Nov 12 13:34:32 2012 +0000 @@ -496,6 +496,7 @@ label_projects_more: More projects label_project_tags_all: Tags for projects label_projects_busy: Busy projects + label_institutions_busy: Busy institutions label_managers: Managed by label_issue: Issue label_issue_new: New issue @@ -562,6 +563,7 @@ label_activity_my_recent_none: No recent activity label_overall_activity: Overall activity label_user_activity: "%{value}'s activity" + label_institution_activity: "Activity from %{value}" label_new: New label_logged_as: Logged in as label_environment: Environment
--- a/config/routes.rb Mon Nov 12 13:34:21 2012 +0000 +++ b/config/routes.rb Mon Nov 12 13:34:32 2012 +0000 @@ -32,7 +32,7 @@ # TODO: wasteful since this is also nested under issues, projects, and projects/issues map.resources :time_entries, :controller => 'timelog' - map.connect 'browse', :controller => 'projects', :action => 'browse' + map.connect 'explore', :controller => 'projects', :action => 'explore' map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post} map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :get}