# HG changeset patch # User Chris Cannam # Date 1363093251 0 # Node ID 194867efafa9bb56b0fb91cf7b9f3caad8169afa # Parent 68a94715fb56b89c5158e08d28a1824e39ca8cf3# Parent 875b5b4c574d8b356f41f1c0bfc0b37e6ba944cb Merge from branch "cannam" diff -r 68a94715fb56 -r 194867efafa9 app/controllers/my_controller.rb --- a/app/controllers/my_controller.rb Tue Feb 12 10:37:52 2013 +0000 +++ b/app/controllers/my_controller.rb Tue Mar 12 13:00:51 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'], diff -r 68a94715fb56 -r 194867efafa9 app/controllers/users_controller.rb --- a/app/controllers/users_controller.rb Tue Feb 12 10:37:52 2013 +0000 +++ b/app/controllers/users_controller.rb Tue Mar 12 13:00:51 2013 +0000 @@ -71,15 +71,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 diff -r 68a94715fb56 -r 194867efafa9 app/helpers/activities_helper.rb --- a/app/helpers/activities_helper.rb Tue Feb 12 10:37:52 2013 +0000 +++ b/app/helpers/activities_helper.rb Tue Mar 12 13:00:51 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,57 @@ end end + projhash + end + + def projects_by_activity(user, count) + + # Return up to count of the user's projects ordered by that user's + # recent activity, omitting any projects for which no activity + # occurred in the recent past + + activity = Redmine::Activity::Fetcher.new(user, :author => user) + 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 = "" + + for c in colleagues + u = User.find_by_id(c) + active_projects = projects_by_activity(u, 3) + if !active_projects.empty? + s << "
" + s << link_to_user(u) + s << "" + s << h(u.ssamr_user_detail.institution_name) + s << "" + s << "
" + s << "
" + s << l(:label_working_in) << " " + s << (active_projects.map { |p| link_to_project(p) }.join ", ") + s << "
" + end + end + + if s != "" + s + else + l(:label_no_active_colleagues) + 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 diff -r 68a94715fb56 -r 194867efafa9 app/helpers/my_helper.rb --- a/app/helpers/my_helper.rb Tue Feb 12 10:37:52 2013 +0000 +++ b/app/helpers/my_helper.rb Tue Mar 12 13:00:51 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 diff -r 68a94715fb56 -r 194867efafa9 app/models/project.rb --- a/app/models/project.rb Tue Feb 12 10:37:52 2013 +0000 +++ b/app/models/project.rb Tue Mar 12 13:00:51 2013 +0000 @@ -473,7 +473,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 @@ -488,7 +488,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 diff -r 68a94715fb56 -r 194867efafa9 app/views/my/blocks/_colleagues.html.erb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/views/my/blocks/_colleagues.html.erb Tue Mar 12 13:00:51 2013 +0000 @@ -0,0 +1,11 @@ + +<% colleagues = all_colleagues_of(@user) %> + +<% if !colleagues.empty? %> +

<%=l(:label_my_colleagues)%>

+
+ <%= render_active_colleagues(colleagues) %> +
+<% end %> + + diff -r 68a94715fb56 -r 194867efafa9 app/views/projects/explore.html.erb --- a/app/views/projects/explore.html.erb Tue Feb 12 10:37:52 2013 +0000 +++ b/app/views/projects/explore.html.erb Tue Mar 12 13:00:51 2013 +0000 @@ -8,14 +8,25 @@

<%= l(:label_explore_projects) %>

+
<% cache(:action => 'explore', :action_suffix => 'tags', :expires_in => 1.hour) do %>

<%=l(:label_project_tags_all)%>

<%= render :partial => 'projects/tagcloud' %>
<% end %> +
-
+
+ <% cache(:action => 'explore', :action_suffix => 'mature_projects', :expires_in => 1.hour) do %> +
+

<%=l(:label_projects_mature)%>

+ <%= render :partial => 'projects/mature' %> +
+ <% end %> +
+ +
<% cache(:action => 'explore', :action_suffix => 'busy_institutions', :expires_in => 1.hour) do %>

<%=l(:label_institutions_busy)%>

@@ -23,13 +34,17 @@ <%= link_to l(:label_overall_activity), { :controller => 'activities', :action => 'index' }, :class => 'more' %>
<% end %> +
+ +

<%=l(:label_project_latest)%>

<%= render :partial => 'projects/latest' %> <%= link_to l(:label_projects_more), { :controller => 'projects' }, :class => 'more' %>
-
+ +
<% cache(:action => 'explore', :action_suffix => 'busy_projects', :expires_in => 1.hour) do %>

<%=l(:label_projects_busy)%>

@@ -37,10 +52,6 @@ <%= link_to l(:label_overall_activity), { :controller => 'activities', :action => 'index' }, :class => 'more' %>
<% end %> - <% cache(:action => 'explore', :action_suffix => 'mature_projects', :expires_in => 1.hour) do %> -
-

<%=l(:label_projects_mature)%>

- <%= render :partial => 'projects/mature' %> -
- <% end %>
+ +<% html_title(l(:label_explore_projects)) -%> diff -r 68a94715fb56 -r 194867efafa9 config/locales/en.yml --- a/config/locales/en.yml Tue Feb 12 10:37:52 2013 +0000 +++ b/config/locales/en.yml Tue Mar 12 13:00:51 2013 +0000 @@ -883,6 +883,9 @@ label_parent_revision: Parent label_child_revision: Child label_export_options: %{export_format} export options + label_my_colleagues: People I'm working with + label_working_in: Working in + label_no_active_colleagues: No recent activity button_login: Login button_submit: Submit diff -r 68a94715fb56 -r 194867efafa9 public/stylesheets/application.css --- a/public/stylesheets/application.css Tue Feb 12 10:37:52 2013 +0000 +++ b/public/stylesheets/application.css Tue Mar 12 13:00:51 2013 +0000 @@ -282,6 +282,11 @@ .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;} diff -r 68a94715fb56 -r 194867efafa9 public/themes/soundsoftware/stylesheets/application.css --- a/public/themes/soundsoftware/stylesheets/application.css Tue Feb 12 10:37:52 2013 +0000 +++ b/public/themes/soundsoftware/stylesheets/application.css Tue Mar 12 13:00:51 2013 +0000 @@ -79,6 +79,9 @@ .box .more { margin-left: 40px; } +.box .institution { font-size: 0.95em; } +.box .active { margin-left: 2em; } + #content .tabs { margin-bottom: 0; } table.list th { background-color: #fdfaf0; border-bottom: 1px solid #a9b680; } diff -r 68a94715fb56 -r 194867efafa9 vendor/plugins/redmine_tags/app/views/projects/index.html.erb --- a/vendor/plugins/redmine_tags/app/views/projects/index.html.erb Tue Feb 12 10:37:52 2013 +0000 +++ b/vendor/plugins/redmine_tags/app/views/projects/index.html.erb Tue Mar 12 13:00:51 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) %>
- -
-<% if User.current.logged? %> -
-
Looking for a list of your own projects?
It's moved to <%= link_to l(:label_my_page), { :controller => 'my', :action => 'page' } %>.
-
-<% end %> -

<%= l("label_project_all") %>