1
|
# encoding: utf-8
|
2
|
#
|
3
|
# Redmine - project management software
|
4
|
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
5
|
#
|
6
|
# This program is free software; you can redistribute it and/or
|
7
|
# modify it under the terms of the GNU General Public License
|
8
|
# as published by the Free Software Foundation; either version 2
|
9
|
# of the License, or (at your option) any later version.
|
10
|
#
|
11
|
# This program is distributed in the hope that it will be useful,
|
12
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
# GNU General Public License for more details.
|
15
|
#
|
16
|
# You should have received a copy of the GNU General Public License
|
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.
|
19
|
|
20
|
module MyHelper
|
21
|
def calendar_items(startdt, enddt)
|
22
|
Issue.visible.
|
23
|
where(:project_id => User.current.projects.map(&:id)).
|
24
|
where("(start_date>=? and start_date<=?) or (due_date>=? and due_date<=?)", startdt, enddt, startdt, enddt).
|
25
|
includes(:project, :tracker, :priority, :assigned_to).
|
26
|
all
|
27
|
end
|
28
|
|
29
|
def documents_items
|
30
|
Document.visible.order("#{Document.table_name}.created_on DESC").all
|
31
|
end
|
32
|
|
33
|
def issuesassignedtome_items
|
34
|
Issue.visible.open.
|
35
|
where(:assigned_to_id => ([User.current.id] + User.current.group_ids)).
|
36
|
includes(:status, :project, :tracker, :priority).
|
37
|
order("#{IssuePriority.table_name}.position DESC, #{Issue.table_name}.updated_on DESC").
|
38
|
all
|
39
|
end
|
40
|
|
41
|
def issuesreportedbyme_items
|
42
|
Issue.visible.open.
|
43
|
where(:author_id => User.current.id).
|
44
|
includes(:status, :project, :tracker, :priority).
|
45
|
order("#{IssuePriority.table_name}.position DESC, #{Issue.table_name}.updated_on DESC").
|
46
|
all
|
47
|
end
|
48
|
|
49
|
def issueswatched_items
|
50
|
Issue.visible.open.watched_by(User.current.id).
|
51
|
includes(:status, :project, :tracker, :priority).
|
52
|
order("#{IssuePriority.table_name}.position DESC, #{Issue.table_name}.updated_on DESC").
|
53
|
all
|
54
|
end
|
55
|
|
56
|
def news_items
|
57
|
News.visible.
|
58
|
where(:project_id => User.current.projects.map(&:id)).
|
59
|
includes(:project, :author).
|
60
|
order("#{News.table_name}.created_on DESC").
|
61
|
all
|
62
|
end
|
63
|
|
64
|
def timelog_items
|
65
|
TimeEntry.
|
66
|
where("#{TimeEntry.table_name}.user_id = ? AND #{TimeEntry.table_name}.spent_on BETWEEN ? AND ?", User.current.id, Date.today - 6, Date.today).
|
67
|
includes(:activity, :project, {:issue => [:tracker, :status]}).
|
68
|
order("#{TimeEntry.table_name}.spent_on DESC, #{Project.table_name}.name ASC, #{Tracker.table_name}.position ASC, #{Issue.table_name}.id ASC").
|
69
|
all
|
70
|
end
|
71
|
end
|