Mercurial > hg > soundsoftware-site
changeset 1218:194867efafa9 live
Merge from branch "cannam"
author | Chris Cannam |
---|---|
date | Tue, 12 Mar 2013 13:00:51 +0000 |
parents | 68a94715fb56 (current diff) 875b5b4c574d (diff) |
children | 3286032e15cf |
files | |
diffstat | 11 files changed, 107 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- 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'],
--- 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
--- 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 << "<div class='user'>" + s << link_to_user(u) + s << "<span class='institution'>" + s << h(u.ssamr_user_detail.institution_name) + s << "</span>" + s << "</div>" + s << "<div class='active'>" + s << l(:label_working_in) << " " + s << (active_projects.map { |p| link_to_project(p) }.join ", ") + s << "</div>" + 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
--- 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
--- 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
--- /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? %> + <h3><%=l(:label_my_colleagues)%></h3> + <div class="box"> + <%= render_active_colleagues(colleagues) %> + </div> +<% end %> + +
--- 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 @@ <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 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
--- 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;}
--- 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; }
--- 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) %> </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") %>