Chris@909: # encoding: utf-8 Chris@909: # Chris@909: # Redmine - project management software Chris@1295: # Copyright (C) 2006-2013 Jean-Philippe Lang Chris@0: # Chris@0: # This program is free software; you can redistribute it and/or Chris@0: # modify it under the terms of the GNU General Public License Chris@0: # as published by the Free Software Foundation; either version 2 Chris@0: # of the License, or (at your option) any later version. Chris@909: # Chris@0: # This program is distributed in the hope that it will be useful, Chris@0: # but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@0: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@0: # GNU General Public License for more details. Chris@909: # Chris@0: # You should have received a copy of the GNU General Public License Chris@0: # along with this program; if not, write to the Free Software Chris@0: # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Chris@0: Chris@0: module MyHelper Chris@1295: def calendar_items(startdt, enddt) Chris@1295: Issue.visible. Chris@1295: where(:project_id => User.current.projects.map(&:id)). Chris@1295: where("(start_date>=? and start_date<=?) or (due_date>=? and due_date<=?)", startdt, enddt, startdt, enddt). Chris@1295: includes(:project, :tracker, :priority, :assigned_to). Chris@1295: all Chris@1295: end Chris@1295: Chris@1295: def documents_items Chris@1295: Document.visible.order("#{Document.table_name}.created_on DESC").limit(10).all Chris@1295: end Chris@1295: Chris@1295: def issuesassignedtome_items Chris@1295: Issue.visible.open. Chris@1295: where(:assigned_to_id => ([User.current.id] + User.current.group_ids)). Chris@1295: limit(10). Chris@1295: includes(:status, :project, :tracker, :priority). Chris@1295: order("#{IssuePriority.table_name}.position DESC, #{Issue.table_name}.updated_on DESC"). Chris@1295: all Chris@1295: end Chris@1295: Chris@1295: def issuesreportedbyme_items Chris@1295: Issue.visible. Chris@1295: where(:author_id => User.current.id). Chris@1295: limit(10). Chris@1295: includes(:status, :project, :tracker). Chris@1295: order("#{Issue.table_name}.updated_on DESC"). Chris@1295: all Chris@1295: end Chris@1295: Chris@1295: def issueswatched_items Chris@1295: Issue.visible.on_active_project.watched_by(User.current.id).recently_updated.limit(10).all Chris@1295: end Chris@1295: Chris@1295: def news_items Chris@1295: News.visible. Chris@1295: where(:project_id => User.current.projects.map(&:id)). Chris@1295: limit(10). Chris@1295: includes(:project, :author). Chris@1295: order("#{News.table_name}.created_on DESC"). Chris@1295: all Chris@1295: end Chris@1295: Chris@1295: def timelog_items Chris@1295: TimeEntry. Chris@1295: where("#{TimeEntry.table_name}.user_id = ? AND #{TimeEntry.table_name}.spent_on BETWEEN ? AND ?", User.current.id, Date.today - 6, Date.today). Chris@1295: includes(:activity, :project, {:issue => [:tracker, :status]}). Chris@1295: order("#{TimeEntry.table_name}.spent_on DESC, #{Project.table_name}.name ASC, #{Tracker.table_name}.position ASC, #{Issue.table_name}.id ASC"). Chris@1295: all Chris@1295: end Chris@0: end