Chris@909
|
1 # encoding: utf-8
|
Chris@909
|
2 #
|
Chris@909
|
3 # Redmine - project management software
|
Chris@1295
|
4 # Copyright (C) 2006-2013 Jean-Philippe Lang
|
Chris@0
|
5 #
|
Chris@0
|
6 # This program is free software; you can redistribute it and/or
|
Chris@0
|
7 # modify it under the terms of the GNU General Public License
|
Chris@0
|
8 # as published by the Free Software Foundation; either version 2
|
Chris@0
|
9 # of the License, or (at your option) any later version.
|
Chris@909
|
10 #
|
Chris@0
|
11 # This program is distributed in the hope that it will be useful,
|
Chris@0
|
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Chris@0
|
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Chris@0
|
14 # GNU General Public License for more details.
|
Chris@909
|
15 #
|
Chris@0
|
16 # You should have received a copy of the GNU General Public License
|
Chris@0
|
17 # along with this program; if not, write to the Free Software
|
Chris@0
|
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Chris@0
|
19
|
Chris@0
|
20 module MyHelper
|
chris@1217
|
21
|
chris@1224
|
22 def all_colleagues_of(user)
|
chris@1224
|
23 # Return a list of all user ids who have worked with the given user
|
chris@1224
|
24 # (on projects that are visible to the current user)
|
chris@1224
|
25 user.projects.select { |p| p.visible? }.map { |p| p.members.map { |m| m.user_id } }.flatten.sort.uniq.reject { |i| user.id == i }
|
chris@1224
|
26 end
|
chris@1224
|
27
|
Chris@1295
|
28 def calendar_items(startdt, enddt)
|
Chris@1295
|
29 Issue.visible.
|
Chris@1295
|
30 where(:project_id => User.current.projects.map(&:id)).
|
Chris@1295
|
31 where("(start_date>=? and start_date<=?) or (due_date>=? and due_date<=?)", startdt, enddt, startdt, enddt).
|
Chris@1295
|
32 includes(:project, :tracker, :priority, :assigned_to).
|
Chris@1295
|
33 all
|
Chris@1295
|
34 end
|
Chris@1295
|
35
|
Chris@1295
|
36 def documents_items
|
Chris@1295
|
37 Document.visible.order("#{Document.table_name}.created_on DESC").limit(10).all
|
Chris@1295
|
38 end
|
Chris@1295
|
39
|
Chris@1295
|
40 def issuesassignedtome_items
|
Chris@1295
|
41 Issue.visible.open.
|
Chris@1295
|
42 where(:assigned_to_id => ([User.current.id] + User.current.group_ids)).
|
Chris@1295
|
43 limit(10).
|
Chris@1295
|
44 includes(:status, :project, :tracker, :priority).
|
Chris@1295
|
45 order("#{IssuePriority.table_name}.position DESC, #{Issue.table_name}.updated_on DESC").
|
Chris@1295
|
46 all
|
Chris@1295
|
47 end
|
Chris@1295
|
48
|
Chris@1295
|
49 def issuesreportedbyme_items
|
Chris@1295
|
50 Issue.visible.
|
Chris@1295
|
51 where(:author_id => User.current.id).
|
Chris@1295
|
52 limit(10).
|
Chris@1295
|
53 includes(:status, :project, :tracker).
|
Chris@1295
|
54 order("#{Issue.table_name}.updated_on DESC").
|
Chris@1295
|
55 all
|
Chris@1295
|
56 end
|
Chris@1295
|
57
|
Chris@1295
|
58 def issueswatched_items
|
Chris@1295
|
59 Issue.visible.on_active_project.watched_by(User.current.id).recently_updated.limit(10).all
|
Chris@1295
|
60 end
|
Chris@1295
|
61
|
Chris@1295
|
62 def news_items
|
Chris@1295
|
63 News.visible.
|
Chris@1295
|
64 where(:project_id => User.current.projects.map(&:id)).
|
Chris@1295
|
65 limit(10).
|
Chris@1295
|
66 includes(:project, :author).
|
Chris@1295
|
67 order("#{News.table_name}.created_on DESC").
|
Chris@1295
|
68 all
|
Chris@1295
|
69 end
|
Chris@1295
|
70
|
Chris@1295
|
71 def timelog_items
|
Chris@1295
|
72 TimeEntry.
|
Chris@1295
|
73 where("#{TimeEntry.table_name}.user_id = ? AND #{TimeEntry.table_name}.spent_on BETWEEN ? AND ?", User.current.id, Date.today - 6, Date.today).
|
Chris@1295
|
74 includes(:activity, :project, {:issue => [:tracker, :status]}).
|
Chris@1295
|
75 order("#{TimeEntry.table_name}.spent_on DESC, #{Project.table_name}.name ASC, #{Tracker.table_name}.position ASC, #{Issue.table_name}.id ASC").
|
Chris@1295
|
76 all
|
Chris@1295
|
77 end
|
Chris@0
|
78 end
|