Mercurial > hg > soundsoftware-site
comparison app/helpers/my_helper.rb @ 1225:edf7563e2653 live
Merge from branch "cannam"
author | Chris Cannam |
---|---|
date | Tue, 12 Mar 2013 15:14:07 +0000 |
parents | 30c444ea1338 |
children | d280360758e5 |
comparison
equal
deleted
inserted
replaced
1220:31aee88c279b | 1225:edf7563e2653 |
---|---|
17 # along with this program; if not, write to the Free Software | 17 # along with this program; if not, write to the Free Software |
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
19 | 19 |
20 module MyHelper | 20 module MyHelper |
21 | 21 |
22 def all_colleagues_of(user) | 22 def all_colleagues_of(user) |
23 # Return a list of all user ids who have worked with the given user | 23 # Return a list of all user ids who have worked with the given user |
24 # (on projects that are visible to the current user) | 24 # (on projects that are visible to the current user) |
25 user.projects.select { |p| p.visible? }.map { |p| p.members.map { |m| m.user_id } }.flatten.sort.uniq.reject { |i| user.id == i } | 25 user.projects.select { |p| p.visible? }.map { |p| p.members.map { |m| m.user_id } }.flatten.sort.uniq.reject { |i| user.id == i } |
26 end | 26 end |
27 | |
28 def render_active_colleagues(colleagues) | |
29 | |
30 s = "" | |
31 | |
32 start = Time.now | |
33 | |
34 my_inst = "" | |
35 if ! User.current.ssamr_user_detail.nil? | |
36 my_inst = User.current.ssamr_user_detail.institution_name | |
37 end | |
38 | |
39 for c in colleagues | |
40 u = User.find_by_id(c) | |
41 active_projects = projects_by_activity(u, 3) | |
42 if !active_projects.empty? | |
43 s << "<div class='active-person'>" | |
44 s << avatar(u, :size => '24') | |
45 s << "<span class='user'>" | |
46 s << h(u.name) | |
47 s << "</span>" | |
48 if !u.ssamr_user_detail.nil? | |
49 inst = u.ssamr_user_detail.institution_name | |
50 if inst != "" and inst != my_inst | |
51 s << " - <span class='institution'>" | |
52 s << h(inst) | |
53 s << "</span>" | |
54 end | |
55 end | |
56 s << "<br>" | |
57 s << "<span class='active'>" | |
58 s << (active_projects.map { |p| link_to_project(p) }.join ", ") | |
59 s << "</span>" | |
60 s << "</div>" | |
61 end | |
62 end | |
63 | |
64 finish = Time.now | |
65 logger.info "render_active_colleagues: took #{finish-start}" | |
66 | |
67 if s != "" | |
68 s | |
69 else | |
70 l(:label_no_active_colleagues) | |
71 end | |
72 end | |
27 | 73 |
28 end | 74 end |