Mercurial > hg > soundsoftware-site
changeset 1229:96790506f247 redmine-2.2-integration
Merge from branch "cannam"
author | Chris Cannam |
---|---|
date | Wed, 13 Mar 2013 10:48:14 +0000 |
parents | 1186340b4ad4 (current diff) 44475ccf56d3 (diff) |
children | a99935447dc6 |
files | app/controllers/my_controller.rb app/controllers/users_controller.rb app/helpers/my_helper.rb app/models/project.rb config/environment.rb config/locales/en.yml plugins/redmine_tags/app/views/projects/index.html.erb public/stylesheets/application.css public/themes/soundsoftware/stylesheets/application.css |
diffstat | 11 files changed, 143 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/app/controllers/my_controller.rb Thu Mar 07 13:05:22 2013 +0000 +++ b/app/controllers/my_controller.rb Wed Mar 13 10:48:14 2013 +0000 @@ -22,6 +22,7 @@ helper :users helper :custom_fields helper :projects + helper :activities BLOCKS = { 'issuesassignedtome' => :label_assigned_to_me_issues, 'issuesreportedbyme' => :label_reported_issues, @@ -32,7 +33,8 @@ 'calendar' => :label_calendar, 'documents' => :label_document_plural, 'timelog' => :label_spent_time, - 'myprojects' => :label_my_projects + 'myprojects' => :label_my_projects, + 'colleagues' => :label_my_colleagues }.merge(Redmine::Views::MyPage::Block.additional_blocks).freeze DEFAULT_LAYOUT = { 'left' => ['myprojects', 'activitymyprojects'],
--- a/app/controllers/users_controller.rb Thu Mar 07 13:05:22 2013 +0000 +++ b/app/controllers/users_controller.rb Wed Mar 13 10:48:14 2013 +0000 @@ -65,15 +65,7 @@ if @user.ssamr_user_detail != nil @description = @user.ssamr_user_detail.description - - if @user.ssamr_user_detail.institution_type != nil - # institution_type is true for listed institutions - if (@user.ssamr_user_detail.institution_type) - @institution_name = Institution.find(@user.ssamr_user_detail.institution_id).name - else - @institution_name = @user.ssamr_user_detail.other_institution - end - end + @institution_name = @user.ssamr_user_detail.institution_name end # show projects based on current user visibility
--- a/app/helpers/activities_helper.rb Thu Mar 07 13:05:22 2013 +0000 +++ b/app/helpers/activities_helper.rb Wed Mar 13 10:48:14 2013 +0000 @@ -15,11 +15,11 @@ end end - def busy_projects(events, count) + def project_activity_on_events(events) # Score each project for which there are any events, by giving # each event a score based on how long ago it was (the more recent - # the better). + # the better). Return a hash mapping project id to score. projhash = Hash.new @@ -40,6 +40,89 @@ end end + projhash + end + + def projects_by_activity(user, count) + + # Return up to count of the user's project ids ordered by that user's + # recent activity, omitting any projects for which no activity + # occurred in the recent past and any projects not visible to + # the current user + + activity = Redmine::Activity::Fetcher.new(User.current, :author => user) + + # Limit scope so as to exclude issues (which non-members can add) + activity.scope = [ "changesets", "files", "documents", "news", "wiki_edits", "messages", "time_entries", "publications" ] + + days = Setting.activity_days_default.to_i + events = activity.events(Date.today - days, Date.today + 1) + projhash = project_activity_on_events(events) + projhash.keys.sort_by { |k| -projhash[k] }.first(count) + end + + def render_active_colleagues(colleagues) + + s = "" + + start = Time.now + + my_inst = "" + if ! User.current.ssamr_user_detail.nil? + my_inst = User.current.ssamr_user_detail.institution_name + end + + actives = Hash.new + for c in colleagues + u = User.find_by_id(c) + active_projects = projects_by_activity(u, 3) + if !active_projects.empty? + actives[c] = active_projects + end + end + + if actives.empty? + l(:label_no_active_colleagues) + else + + s << "<dl>" + for c in actives.keys.sample(10) + u = User.find_by_id(c) + s << "<dt>" + s << avatar(u, :size => '24') + s << "<span class='user'>" + s << h(u.name) + s << "</span>" + if !u.ssamr_user_detail.nil? + inst = u.ssamr_user_detail.institution_name + if inst != "" and inst != my_inst + s << " - <span class='institution'>" + s << h(u.ssamr_user_detail.institution_name) + s << "</span>" + end + end + s << "</dt>" + s << "<dd>" + s << "<span class='active'>" + s << (actives[c].map { |p| link_to_project(p) }.join ", ") + s << "</span>" + end + s << "</dl>" + + finish = Time.now + logger.info "render_active_colleagues: took #{finish-start}" + + s + end + end + + def busy_projects(events, count) + + # Return a list of count projects randomly selected from amongst + # the busiest projects represented by the given activity events + + projhash = project_activity_on_events(events) + # pick N highest values and use cutoff value as selection threshold threshold = projhash.values.sort.last(count).first
--- a/app/helpers/my_helper.rb Thu Mar 07 13:05:22 2013 +0000 +++ b/app/helpers/my_helper.rb Wed Mar 13 10:48:14 2013 +0000 @@ -18,4 +18,11 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. module MyHelper + + def all_colleagues_of(user) + # Return a list of all user ids who have worked with the given user + # (on projects that are visible to the current user) + user.projects.select { |p| p.visible? }.map { |p| p.members.map { |m| m.user_id } }.flatten.sort.uniq.reject { |i| user.id == i } + end + end
--- a/app/models/project.rb Thu Mar 07 13:05:22 2013 +0000 +++ b/app/models/project.rb Wed Mar 13 10:48:14 2013 +0000 @@ -515,7 +515,7 @@ end # Returns a short description of the projects (first lines) - def short_description(length = 255) + def short_description(length = 200) ## The short description is used in lists, e.g. Latest projects, ## My projects etc. It should be no more than a line or two with @@ -530,7 +530,7 @@ ## follows _any_ non-blank text, and to the next word break beyond ## "length" characters if the result is still longer than that. ## - description.gsub(/![^\s]+!/, '').gsub(/^(\s*[^\n\r]*).*$/m, '\1').gsub(/^(.{#{length}}\b).*$/m, '\1 ...').strip if description + description.gsub(/![^\s]+!/, '').gsub(/^(\s*[^\n\r]*).*$/m, '\1').gsub(/^(.{#{length}}[^\.;:,-]*).*$/m, '\1 ...').strip if description end def css_classes
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/views/my/blocks/_colleagues.html.erb Wed Mar 13 10:48:14 2013 +0000 @@ -0,0 +1,13 @@ + +<% colleagues = all_colleagues_of(@user) %> + +<% if !colleagues.empty? %> +<div id="activity"> + <h3><%=l(:label_my_colleagues)%></h3> + <div class="activity box" id="active-colleagues"> + <%= render_active_colleagues(colleagues) %> + </div> +</div> +<% end %> + +
--- a/app/views/projects/explore.html.erb Thu Mar 07 13:05:22 2013 +0000 +++ b/app/views/projects/explore.html.erb Wed Mar 13 10:48:14 2013 +0000 @@ -8,14 +8,25 @@ <h2><%= l(:label_explore_projects) %></h2> +<div class="threecolumnleft"> <% cache(:action => 'explore', :action_suffix => 'tags', :expires_in => 1.hour) do %> <div class="tags box"> <h3><%=l(:label_project_tags_all)%></h3> <%= render :partial => 'projects/tagcloud' %> </div> <% end %> +</div> -<div class="splitcontentleft"> +<div class="threecolumnright"> + <% cache(:action => 'explore', :action_suffix => 'mature_projects', :expires_in => 1.hour) do %> + <div class="projects box"> + <h3><%=l(:label_projects_mature)%></h3> + <%= render :partial => 'projects/mature' %> + </div> + <% end %> +</div> + +<div class="threecolumnleft"> <% cache(:action => 'explore', :action_suffix => 'busy_institutions', :expires_in => 1.hour) do %> <div class="institutions box"> <h3><%=l(:label_institutions_busy)%></h3> @@ -23,13 +34,17 @@ <%= link_to l(:label_overall_activity), { :controller => 'activities', :action => 'index' }, :class => 'more' %> </div> <% end %> +</div> + +<div class="threecolumnright"> <div class="projects box"> <h3><%=l(:label_project_latest)%></h3> <%= render :partial => 'projects/latest' %> <%= link_to l(:label_projects_more), { :controller => 'projects' }, :class => 'more' %> </div> </div> -<div class="splitcontentright"> + +<div class="threecolumnmid"> <% cache(:action => 'explore', :action_suffix => 'busy_projects', :expires_in => 1.hour) do %> <div class="projects box"> <h3><%=l(:label_projects_busy)%></h3> @@ -37,10 +52,6 @@ <%= link_to l(:label_overall_activity), { :controller => 'activities', :action => 'index' }, :class => 'more' %> </div> <% end %> - <% cache(:action => 'explore', :action_suffix => 'mature_projects', :expires_in => 1.hour) do %> - <div class="projects box"> - <h3><%=l(:label_projects_mature)%></h3> - <%= render :partial => 'projects/mature' %> - </div> - <% end %> </div> + +<% html_title(l(:label_explore_projects)) -%>
--- a/config/locales/en.yml Thu Mar 07 13:05:22 2013 +0000 +++ b/config/locales/en.yml Wed Mar 13 10:48:14 2013 +0000 @@ -924,6 +924,9 @@ label_parent_revision: Parent label_child_revision: Child label_export_options: "%{export_format} export options" + label_my_colleagues: "Active projects for people I'm working with" + label_working_in: Working in + label_no_active_colleagues: No recent activity label_copy_attachments: Copy attachments label_copy_subtasks: Copy subtasks label_item_position: "%{position} of %{count}"
--- a/plugins/redmine_tags/app/views/projects/index.html.erb Thu Mar 07 13:05:22 2013 +0000 +++ b/plugins/redmine_tags/app/views/projects/index.html.erb Wed Mar 13 10:48:14 2013 +0000 @@ -10,14 +10,6 @@ <%= '| ' + link_to(l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %> </div> - -<div style="clear:both;"></div> -<% if User.current.logged? %> -<div class="splitcontentleft"> - <div class=box><b>Looking for a list of your own projects?</b><br>It's moved to <%= link_to l(:label_my_page), { :controller => 'my', :action => 'page' } %>.</div> -</div> -<% end %> - <div style="clear:both;"></div> <h2> <%= l("label_project_all") %>
--- a/public/stylesheets/application.css Thu Mar 07 13:05:22 2013 +0000 +++ b/public/stylesheets/application.css Wed Mar 13 10:48:14 2013 +0000 @@ -313,6 +313,11 @@ .splitcontent {overflow:auto;} .splitcontentleft{float:left; width:49%;} .splitcontentright{float:right; width:49%;} + +.threecolumnleft{float:left; clear:left; width: 32%;} +.threecolumnright{float:right; clear:right; width: 32%;} +.threecolumnmid{margin-left: 33%; margin-right: 33%;} + form {display: inline;} input, select {vertical-align: middle; margin-top: 1px; margin-bottom: 1px;} fieldset {border: 1px solid #e4e4e4; margin:0;} @@ -1078,9 +1083,10 @@ vertical-align: top; } -#activity dt img.gravatar, #members dt img.gravatar { +#activity dt img.gravatar, #members dt img.gravatar, #active-colleagues img.gravatar { float: left; - margin: 0 1em 1em 0; + clear: left; + margin: 0.2em 1em 0.4em 0; } /* Used on 12px Gravatar img tags without the icon background */
--- a/public/themes/soundsoftware/stylesheets/application.css Thu Mar 07 13:05:22 2013 +0000 +++ b/public/themes/soundsoftware/stylesheets/application.css Wed Mar 13 10:48:14 2013 +0000 @@ -88,6 +88,8 @@ .box .more { margin-left: 40px; } +.box .institution { font-size: 0.95em; } + #content .tabs { margin-bottom: 0; } table.list th { background-color: #fdfaf0; border-bottom: 1px solid #a9b680; }