Commit 78b2370e authored by jplang's avatar jplang

Dropped TimeEntryReportsController.

git-svn-id: https://svn.redmine.org/redmine/trunk@8027 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent aab71ac7
class TimeEntryReportsController < ApplicationController
menu_item :issues
before_filter :find_optional_project
helper :sort
include SortHelper
helper :issues
helper :timelog
include TimelogHelper
helper :custom_fields
include CustomFieldsHelper
def report
retrieve_date_range
@report = Redmine::Helpers::TimeReport.new(@project, @issue, params[:criteria], params[:columns], @from, @to)
respond_to do |format|
format.html { render :layout => !request.xhr? }
format.csv { send_data(report_to_csv(@report), :type => 'text/csv; header=present', :filename => 'timelog.csv') }
end
end
private
# TODO: duplicated in TimelogController
def find_optional_project
if !params[:issue_id].blank?
@issue = Issue.find(params[:issue_id])
@project = @issue.project
elsif !params[:project_id].blank?
@project = Project.find(params[:project_id])
end
deny_access unless User.current.allowed_to?(:view_time_entries, @project, :global => true)
end
# Retrieves the date range based on predefined ranges or specific from/to param dates
# TODO: duplicated in TimelogController
def retrieve_date_range
@free_period = false
@from, @to = nil, nil
if params[:period_type] == '1' || (params[:period_type].nil? && !params[:period].nil?)
case params[:period].to_s
when 'today'
@from = @to = Date.today
when 'yesterday'
@from = @to = Date.today - 1
when 'current_week'
@from = Date.today - (Date.today.cwday - 1)%7
@to = @from + 6
when 'last_week'
@from = Date.today - 7 - (Date.today.cwday - 1)%7
@to = @from + 6
when '7_days'
@from = Date.today - 7
@to = Date.today
when 'current_month'
@from = Date.civil(Date.today.year, Date.today.month, 1)
@to = (@from >> 1) - 1
when 'last_month'
@from = Date.civil(Date.today.year, Date.today.month, 1) << 1
@to = (@from >> 1) - 1
when '30_days'
@from = Date.today - 30
@to = Date.today
when 'current_year'
@from = Date.civil(Date.today.year, 1, 1)
@to = Date.civil(Date.today.year, 12, 31)
end
elsif params[:period_type] == '2' || (params[:period_type].nil? && (!params[:from].nil? || !params[:to].nil?))
begin; @from = params[:from].to_s.to_date unless params[:from].blank?; rescue; end
begin; @to = params[:to].to_s.to_date unless params[:to].blank?; rescue; end
@free_period = true
else
# default
end
@from, @to = @to, @from if @from && @to && @from > @to
@from ||= (TimeEntry.earilest_date_for_project(@project) || Date.today)
@to ||= (TimeEntry.latest_date_for_project(@project) || Date.today)
end
end
......@@ -20,8 +20,8 @@ class TimelogController < ApplicationController
before_filter :find_project, :only => [:new, :create]
before_filter :find_time_entry, :only => [:show, :edit, :update]
before_filter :find_time_entries, :only => [:bulk_edit, :bulk_update, :destroy]
before_filter :authorize, :except => [:index]
before_filter :find_optional_project, :only => [:index]
before_filter :authorize, :except => [:index, :report]
before_filter :find_optional_project, :only => [:index, :report]
accept_rss_auth :index
accept_api_auth :index, :show, :create, :update, :destroy
......@@ -95,6 +95,16 @@ class TimelogController < ApplicationController
end
end
def report
retrieve_date_range
@report = Redmine::Helpers::TimeReport.new(@project, @issue, params[:criteria], params[:columns], @from, @to)
respond_to do |format|
format.html { render :layout => !request.xhr? }
format.csv { send_data(report_to_csv(@report), :type => 'text/csv; header=present', :filename => 'timelog.csv') }
end
end
def show
respond_to do |format|
# TODO: Implement html response
......
......@@ -68,7 +68,7 @@
<h3><%= l(:label_spent_time) %></h3>
<p><span class="icon icon-time"><%= l_hours(@total_hours) %></span></p>
<p><%= link_to(l(:label_details), {:controller => 'timelog', :action => 'index', :project_id => @project}) %> |
<%= link_to(l(:label_report), {:controller => 'time_entry_reports', :action => 'report', :project_id => @project}) %></p>
<%= link_to(l(:label_report), {:controller => 'timelog', :action => 'report', :project_id => @project}) %></p>
<% end %>
<%= call_hook(:view_projects_show_sidebar_bottom, :project => @project) %>
<% end %>
......
......@@ -32,7 +32,7 @@
<ul>
<li><%= link_to(l(:label_details), url_params.merge({:controller => 'timelog', :action => 'index', :project_id => @project, :issue_id => @issue }),
:class => (@controller.action_name == 'index' ? 'selected' : nil)) %></li>
<li><%= link_to(l(:label_report), url_params.merge({:controller => 'time_entry_reports', :action => 'report', :project_id => @project, :issue_id => @issue}),
<li><%= link_to(l(:label_report), url_params.merge({:controller => 'timelog', :action => 'report', :project_id => @project, :issue_id => @issue}),
:class => (@controller.action_name == 'report' ? 'selected' : nil)) %></li>
</ul>
</div>
......@@ -6,7 +6,7 @@
<h2><%= l(:label_spent_time) %></h2>
<% form_tag({:controller => 'time_entry_reports', :action => 'report', :project_id => @project, :issue_id => @issue}, :method => :get, :id => 'query_form') do %>
<% form_tag({:controller => 'timelog', :action => 'report', :project_id => @project, :issue_id => @issue}, :method => :get, :id => 'query_form') do %>
<% @report.criteria.each do |criterion| %>
<%= hidden_field_tag 'criteria[]', criterion, :id => nil %>
<% end %>
......
......@@ -14,15 +14,6 @@ ActionController::Routing::Routes.draw do |map|
map.connect 'roles/workflow/:id/:role_id/:tracker_id', :controller => 'roles', :action => 'workflow'
map.connect 'help/:ctrl/:page', :controller => 'help'
map.with_options :controller => 'time_entry_reports', :action => 'report',:conditions => {:method => :get} do |time_report|
time_report.connect 'projects/:project_id/issues/:issue_id/time_entries/report'
time_report.connect 'projects/:project_id/issues/:issue_id/time_entries/report.:format'
time_report.connect 'projects/:project_id/time_entries/report'
time_report.connect 'projects/:project_id/time_entries/report.:format'
time_report.connect 'time_entries/report'
time_report.connect 'time_entries/report.:format'
end
map.bulk_edit_time_entry 'time_entries/bulk_edit',
:controller => 'timelog', :action => 'bulk_edit', :conditions => { :method => :get }
map.bulk_update_time_entry 'time_entries/bulk_edit',
......@@ -30,7 +21,7 @@ ActionController::Routing::Routes.draw do |map|
map.time_entries_context_menu '/time_entries/context_menu',
:controller => 'context_menus', :action => 'time_entries'
map.resources :time_entries, :controller => 'timelog'
map.resources :time_entries, :controller => 'timelog', :collection => {:report => :get}
map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post}
map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :get}
......@@ -79,7 +70,7 @@ ActionController::Routing::Routes.draw do |map|
end
map.resources :issues do |issues|
issues.resources :time_entries, :controller => 'timelog'
issues.resources :time_entries, :controller => 'timelog', :collection => {:report => :get}
issues.resources :relations, :shallow => true, :controller => 'issue_relations', :only => [:index, :show, :create, :destroy]
end
......@@ -118,12 +109,12 @@ ActionController::Routing::Routes.draw do |map|
} do |project|
project.resource :project_enumerations, :as => 'enumerations', :only => [:update, :destroy]
project.resources :issues, :only => [:index, :new, :create] do |issues|
issues.resources :time_entries, :controller => 'timelog'
issues.resources :time_entries, :controller => 'timelog', :collection => {:report => :get}
end
project.resources :files, :only => [:index, :new, :create]
project.resources :versions, :shallow => true, :collection => {:close_completed => :put}, :member => {:status_by => :post}
project.resources :news, :shallow => true
project.resources :time_entries, :controller => 'timelog', :path_prefix => 'projects/:project_id'
project.resources :time_entries, :controller => 'timelog', :path_prefix => 'projects/:project_id', :collection => {:report => :get}
project.resources :queries, :only => [:new, :create]
project.resources :issue_categories, :shallow => true
project.resources :documents, :shallow => true, :member => {:add_attachment => :post}
......
......@@ -89,7 +89,7 @@ Redmine::AccessControl.map do |map|
map.project_module :time_tracking do |map|
map.permission :log_time, {:timelog => [:new, :create]}, :require => :loggedin
map.permission :view_time_entries, :timelog => [:index, :show], :time_entry_reports => [:report]
map.permission :view_time_entries, :timelog => [:index, :report, :show]
map.permission :edit_time_entries, {:timelog => [:edit, :update, :destroy, :bulk_edit, :bulk_update]}, :require => :member
map.permission :edit_own_time_entries, {:timelog => [:edit, :update, :destroy,:bulk_edit, :bulk_update]}, :require => :loggedin
map.permission :manage_project_activities, {:project_enumerations => [:update, :destroy]}, :require => :member
......
......@@ -2,6 +2,8 @@
require File.expand_path('../../test_helper', __FILE__)
class TimeEntryReportsControllerTest < ActionController::TestCase
tests TimelogController
fixtures :projects, :enabled_modules, :roles, :members, :member_roles,
:issues, :time_entries, :users, :trackers, :enumerations,
:issue_statuses, :custom_fields, :custom_values
......
......@@ -329,12 +329,10 @@ class RoutingTest < ActionController::IntegrationTest
should_route :put, "/projects/ecookbook/issues/234/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22', :issue_id => '234', :project_id => 'ecookbook'
should_route :delete, "/projects/ecookbook/issues/234/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55', :issue_id => '234', :project_id => 'ecookbook'
end
context "time_entry_reports" do
should_route :get, "/time_entries/report", :controller => 'time_entry_reports', :action => 'report'
should_route :get, "/projects/567/time_entries/report", :controller => 'time_entry_reports', :action => 'report', :project_id => '567'
should_route :get, "/projects/567/time_entries/report.csv", :controller => 'time_entry_reports', :action => 'report', :project_id => '567', :format => 'csv'
should_route :get, "/time_entries/report", :controller => 'timelog', :action => 'report'
should_route :get, "/projects/567/time_entries/report", :controller => 'timelog', :action => 'report', :project_id => '567'
should_route :get, "/projects/567/time_entries/report.csv", :controller => 'timelog', :action => 'report', :project_id => '567', :format => 'csv'
end
context "users" do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment