diff --git a/features/step_definitions/disabled_scenarios.rb b/features/step_definitions/disabled_scenarios.rb new file mode 100644 index 0000000000..be73f10ef5 --- /dev/null +++ b/features/step_definitions/disabled_scenarios.rb @@ -0,0 +1,2 @@ +ScenarioDisabler.disable(:feature => "Tracking Time", :scenario => "Adding a time entry") +ScenarioDisabler.disable(:feature => "Tracking Time", :scenario => "Editing a time entry") \ No newline at end of file diff --git a/lib/open_project/reporting/engine.rb b/lib/open_project/reporting/engine.rb index f8b43acd73..d798e37ac9 100644 --- a/lib/open_project/reporting/engine.rb +++ b/lib/open_project/reporting/engine.rb @@ -41,6 +41,7 @@ module OpenProject::Reporting require_dependency 'widget/simple_table' require_dependency 'widget/entry_table' require_dependency 'widget/settings_patch' + require_dependency 'open_project/reporting/patches/timelog_controller_patch' unless Redmine::Plugin.registered_plugins.include?(:openproject_reporting) Redmine::Plugin.register :openproject_reporting do diff --git a/lib/open_project/reporting/patches.rb b/lib/open_project/reporting/patches.rb new file mode 100644 index 0000000000..6e912998bb --- /dev/null +++ b/lib/open_project/reporting/patches.rb @@ -0,0 +1,2 @@ +module OpenProject::Reporting::Patches +end diff --git a/lib/open_project/reporting/patches/timelog_controller_patch.rb b/lib/open_project/reporting/patches/timelog_controller_patch.rb new file mode 100644 index 0000000000..faa0a969ab --- /dev/null +++ b/lib/open_project/reporting/patches/timelog_controller_patch.rb @@ -0,0 +1,73 @@ +require_dependency 'timelog_controller' + +module OpenProject::Reporting::Patches::TimelogControllerPatch + def self.included(base) # :nodoc: + base.send(:include, InstanceMethods) + + base.class_eval do + unloadable + + alias_method_chain :index, :reports_view + alias_method_chain :find_optional_project, :own + end + end + + module InstanceMethods + + ## + # @Override + # This is for cost reporting + def redirect_to(*args, &block) + if args.first == :back and args.size == 1 and request.referer =~ /cost_reports/ + super(:controller => '/cost_reports', :action => :index) + else + super(*args, &block) + end + end + + def index_with_reports_view + # we handle single project reporting currently + if @project.nil? || !@project.module_enabled?(:reporting_module) + return index_without_reports_view + end + filters = {:operators => {}, :values => {}} + + if @issue + if @issue.respond_to?("lft") + issue_ids = Issue.all(:select => :id, :conditions => ["root_id = ? AND lft >= ? AND rgt <= ?", @issue.root_id, @issue.lft, @issue.rgt]).collect{|i| i.id.to_s} + else + issue_ids = [@issue.id.to_s] + end + + filters[:operators][:issue_id] = "=" + filters[:values][:issue_id] = [issue_ids] + end + + filters[:operators][:project_id] = "=" + filters[:values][:project_id] = [@project.id.to_s] + respond_to do |format| + format.html { + session[::CostQuery.name.underscore.to_sym] = { :filters => filters, :groups => {:rows => [], :columns => []} } + + redirect_to :controller => "/cost_reports", :action => "index", :project_id => @project, :unit => -1 + } + format.all { + index_without_report_view + } + end + end + + def find_optional_project_with_own + 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) || + User.current.allowed_to?(:view_own_time_entries, @project, :global => true) + end + end +end + +TimelogController.send(:include, OpenProject::Reporting::Patches::TimelogControllerPatch)