Project

General

Profile

Customizing "My page" and default "My page" presets » OLD_my_helper.rb

Eugene B, 2014-05-04 12:12

 
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").limit(10).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
      limit(10).
37
      includes(:status, :project, :tracker, :priority).
38
      order("#{IssuePriority.table_name}.position DESC, #{Issue.table_name}.updated_on DESC").
39
      all
40
  end
41

    
42
  def issuesreportedbyme_items
43
    Issue.visible.
44
      where(:author_id => User.current.id).
45
      limit(10).
46
      includes(:status, :project, :tracker).
47
      order("#{Issue.table_name}.updated_on DESC").
48
      all
49
  end
50

    
51
  def issueswatched_items
52
    Issue.visible.on_active_project.watched_by(User.current.id).recently_updated.limit(10).all
53
  end
54

    
55
  def news_items
56
    News.visible.
57
      where(:project_id => User.current.projects.map(&:id)).
58
      limit(10).
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
(10-10/10)