Permalink
Browse files

initial commit

  • Loading branch information...
1 parent df0dc8a commit 8081977fa02e5f9ebaad7b8e0e71ddea0ed4c512 @yeah yeah committed Feb 2, 2011
View
0 README
No changes.
View
@@ -0,0 +1,3 @@
+= spent_time_column
+
+Description goes here
View
14 init.rb
@@ -0,0 +1,14 @@
+require 'redmine'
+require 'dispatcher'
+
+Dispatcher.to_prepare do
+ Query.send(:include, RedmineSpentTimeColumn::Patches::QueryPatch) unless Query.include?(RedmineSpentTimeColumn::Patches::QueryPatch)
+ QueriesHelper.send(:include, RedmineSpentTimeColumn::Patches::QueriesHelperPatch) unless QueriesHelper.include?(RedmineSpentTimeColumn::Patches::QueriesHelperPatch)
+end
+
+Redmine::Plugin.register :redmine_spent_time_column do
+ name 'Redmine Spent Time Column'
+ author 'Jan Schulz-Hofen, Planio GmbH'
+ description 'This plugin adds a spent time column to issue lists.'
+ version '1.0.0'
+end
@@ -0,0 +1,20 @@
+module RedmineSpentTimeColumn
+ module Patches
+ module QueriesHelperPatch
+
+ def column_content_with_spent_hours(column, issue)
+ value = column.value(issue)
+ if %w(Fixnum Float).include?( value.class.name ) and column.name == :spent_hours
+ sprintf "%.2f", value
+ else
+ column_content_without_spent_hours(column, issue)
+ end
+ end
+
+ def self.included(klass)
+ klass.send :alias_method_chain, :column_content, :spent_hours
+ end
+
+ end
+ end
+end
@@ -0,0 +1,19 @@
+module RedmineSpentTimeColumn
+ module Patches
+ module QueryPatch
+
+ def available_columns_with_spent_hours
+ returning available_columns_without_spent_hours do |columns|
+ if (project and User.current.allowed_to?(:view_time_entries, project)) or User.current.admin?
+ columns << QueryColumn.new(:spent_hours, :caption => :label_spent_time, :sortable => "(select sum(hours) from #{TimeEntry.table_name} where #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id)") unless columns.detect{ |c| c.name == :spent_hours }
+ end
+ end
+ end
+
+ def self.included(klass)
+ klass.send :alias_method_chain, :available_columns, :spent_hours
+ end
+
+ end
+ end
+end
View
@@ -0,0 +1,5 @@
+# Load the normal Rails helper
+require File.expand_path(File.dirname(__FILE__) + '/../../../../test/test_helper')
+
+# Ensure that we are using the temporary fixture path
+Engines::Testing.set_fixture_path

0 comments on commit 8081977

Please sign in to comment.