Mercurial > hg > soundsoftware-site
comparison app/helpers/my_helper.rb @ 1298:4f746d8966dd redmine_2.3_integration
Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:28:30 +0100 |
parents | 96790506f247 622f24f53b42 |
children |
comparison
equal
deleted
inserted
replaced
1297:0a574315af3e | 1298:4f746d8966dd |
---|---|
1 # encoding: utf-8 | 1 # encoding: utf-8 |
2 # | 2 # |
3 # Redmine - project management software | 3 # Redmine - project management software |
4 # Copyright (C) 2006-2012 Jean-Philippe Lang | 4 # Copyright (C) 2006-2013 Jean-Philippe Lang |
5 # | 5 # |
6 # This program is free software; you can redistribute it and/or | 6 # This program is free software; you can redistribute it and/or |
7 # modify it under the terms of the GNU General Public License | 7 # modify it under the terms of the GNU General Public License |
8 # as published by the Free Software Foundation; either version 2 | 8 # as published by the Free Software Foundation; either version 2 |
9 # of the License, or (at your option) any later version. | 9 # of the License, or (at your option) any later version. |
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 | 27 |
28 def calendar_items(startdt, enddt) | |
29 Issue.visible. | |
30 where(:project_id => User.current.projects.map(&:id)). | |
31 where("(start_date>=? and start_date<=?) or (due_date>=? and due_date<=?)", startdt, enddt, startdt, enddt). | |
32 includes(:project, :tracker, :priority, :assigned_to). | |
33 all | |
34 end | |
35 | |
36 def documents_items | |
37 Document.visible.order("#{Document.table_name}.created_on DESC").limit(10).all | |
38 end | |
39 | |
40 def issuesassignedtome_items | |
41 Issue.visible.open. | |
42 where(:assigned_to_id => ([User.current.id] + User.current.group_ids)). | |
43 limit(10). | |
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 issuesreportedbyme_items | |
50 Issue.visible. | |
51 where(:author_id => User.current.id). | |
52 limit(10). | |
53 includes(:status, :project, :tracker). | |
54 order("#{Issue.table_name}.updated_on DESC"). | |
55 all | |
56 end | |
57 | |
58 def issueswatched_items | |
59 Issue.visible.on_active_project.watched_by(User.current.id).recently_updated.limit(10).all | |
60 end | |
61 | |
62 def news_items | |
63 News.visible. | |
64 where(:project_id => User.current.projects.map(&:id)). | |
65 limit(10). | |
66 includes(:project, :author). | |
67 order("#{News.table_name}.created_on DESC"). | |
68 all | |
69 end | |
70 | |
71 def timelog_items | |
72 TimeEntry. | |
73 where("#{TimeEntry.table_name}.user_id = ? AND #{TimeEntry.table_name}.spent_on BETWEEN ? AND ?", User.current.id, Date.today - 6, Date.today). | |
74 includes(:activity, :project, {:issue => [:tracker, :status]}). | |
75 order("#{TimeEntry.table_name}.spent_on DESC, #{Project.table_name}.name ASC, #{Tracker.table_name}.position ASC, #{Issue.table_name}.id ASC"). | |
76 all | |
77 end | |
28 end | 78 end |