To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / app / helpers / my_helper.rb @ 1298:4f746d8966dd
History | View | Annotate | Download (2.8 KB)
| 1 | 909:cbb26bc654de | Chris | # encoding: utf-8
|
|---|---|---|---|
| 2 | #
|
||
| 3 | # Redmine - project management software
|
||
| 4 | 1295:622f24f53b42 | Chris | # Copyright (C) 2006-2013 Jean-Philippe Lang
|
| 5 | 0:513646585e45 | Chris | #
|
| 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 | 909:cbb26bc654de | Chris | #
|
| 11 | 0:513646585e45 | Chris | # 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 | 909:cbb26bc654de | Chris | #
|
| 16 | 0:513646585e45 | Chris | # 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 | 1217:875b5b4c574d | chris | |
| 22 | 1224:30c444ea1338 | chris | def all_colleagues_of(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)
|
||
| 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
|
||
| 27 | |||
| 28 | 1295:622f24f53b42 | Chris | 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
|
||
| 78 | 0:513646585e45 | Chris | end |