Changed translations to actually translate upon requesting the label

and not upon creating the class causing language changes in production
to have no effect
pull/6827/head
Sebastian Schuster 12 years ago
parent ef843e2d2b
commit 83d55e316c
  1. 7
      app/models/cost_query/custom_field_mixin.rb
  2. 5
      app/models/cost_query/filter/activity_id.rb
  3. 5
      app/models/cost_query/filter/assigned_to_id.rb
  4. 5
      app/models/cost_query/filter/author_id.rb
  5. 5
      app/models/cost_query/filter/category_id.rb
  6. 5
      app/models/cost_query/filter/cost_object_id.rb
  7. 5
      app/models/cost_query/filter/cost_type_id.rb
  8. 5
      app/models/cost_query/filter/created_on.rb
  9. 5
      app/models/cost_query/filter/due_date.rb
  10. 5
      app/models/cost_query/filter/fixed_version_id.rb
  11. 5
      app/models/cost_query/filter/issue_id.rb
  12. 5
      app/models/cost_query/filter/overridden_costs.rb
  13. 5
      app/models/cost_query/filter/priority_id.rb
  14. 5
      app/models/cost_query/filter/project_id.rb
  15. 5
      app/models/cost_query/filter/spent_on.rb
  16. 5
      app/models/cost_query/filter/start_date.rb
  17. 5
      app/models/cost_query/filter/status_id.rb
  18. 5
      app/models/cost_query/filter/subject.rb
  19. 5
      app/models/cost_query/filter/tmonth.rb
  20. 5
      app/models/cost_query/filter/tracker_id.rb
  21. 5
      app/models/cost_query/filter/tweek.rb
  22. 5
      app/models/cost_query/filter/tyear.rb
  23. 5
      app/models/cost_query/filter/updated_on.rb
  24. 4
      app/models/cost_query/filter/user_id.rb
  25. 5
      app/models/cost_query/group_by/activity_id.rb
  26. 5
      app/models/cost_query/group_by/assigned_to_id.rb
  27. 5
      app/models/cost_query/group_by/author_id.rb
  28. 5
      app/models/cost_query/group_by/category_id.rb
  29. 5
      app/models/cost_query/group_by/cost_object_id.rb
  30. 5
      app/models/cost_query/group_by/cost_type_id.rb
  31. 5
      app/models/cost_query/group_by/fixed_version_id.rb
  32. 5
      app/models/cost_query/group_by/issue_id.rb
  33. 5
      app/models/cost_query/group_by/priority_id.rb
  34. 5
      app/models/cost_query/group_by/project_id.rb
  35. 5
      app/models/cost_query/group_by/spent_on.rb
  36. 5
      app/models/cost_query/group_by/status_id.rb
  37. 5
      app/models/cost_query/group_by/tmonth.rb
  38. 5
      app/models/cost_query/group_by/tracker_id.rb
  39. 5
      app/models/cost_query/group_by/tweek.rb
  40. 5
      app/models/cost_query/group_by/tyear.rb
  41. 5
      app/models/cost_query/group_by/user_id.rb
  42. 5
      app/models/cost_query/group_by/week.rb
  43. 6
      app/models/cost_query/operator.rb

@ -29,7 +29,7 @@ module CostQuery::CustomFieldMixin
class_name = class_name_for field.name
parent.send(:remove_const, class_name) if parent.const_defined? class_name
parent.const_set class_name, Class.new(self)
(parent.const_get class_name).prepare(field, class_name)
parent.const_get(class_name).prepare(field, class_name)
end
end
@ -48,9 +48,12 @@ module CostQuery::CustomFieldMixin
@class_name.demodulize.underscore.tableize.singularize
end
def label
@custom_field.name
end
def prepare(field, class_name)
@custom_field = field
label field.name
@class_name = class_name
dont_inherit :group_fields
db_field table_name

@ -1,5 +1,8 @@
class CostQuery::Filter::ActivityId < CostQuery::Filter::Base
label TimeEntry.human_attribute_name(:activity)
def self.label
TimeEntry.human_attribute_name(:activity)
end
def self.available_values(*)
TimeEntryActivity.find(:all, :order => 'name').map { |a| [a.name, a.id] }

@ -2,7 +2,10 @@ class CostQuery::Filter::AssignedToId < CostQuery::Filter::Base
use :null_operators
join_table Issue
applies_for :label_issue_attributes
label Issue.human_attribute_name(:assigned_to)
def self.label
Issue.human_attribute_name(:assigned_to)
end
def self.available_values(*)
CostQuery::Filter::UserId.available_values

@ -1,7 +1,10 @@
class CostQuery::Filter::AuthorId < CostQuery::Filter::Base
join_table Issue
applies_for :label_issue_attributes
label Issue.human_attribute_name(:author)
def self.label
Issue.human_attribute_name(:author)
end
def self.available_values(*)
CostQuery::Filter::UserId.available_values

@ -2,7 +2,10 @@ class CostQuery::Filter::CategoryId < CostQuery::Filter::Base
use :null_operators
join_table Issue
applies_for :label_issue_attributes
label Issue.human_attribute_name(:category)
def self.label
Issue.human_attribute_name(:category)
end
def self.available_values(*)
categories = IssueCategory.find :all, :conditions => {:project_id => Project.visible.map{|p| p.id}}

@ -1,8 +1,11 @@
class CostQuery::Filter::CostObjectId < CostQuery::Filter::Base
join_table Project
label CostObject.model_name.human
applies_for :label_issue_attributes
def self.label
CostObject.model_name.human
end
def self.available_values(*)
([[l(:caption_labor), -1]] + CostObject.find(:all, :order => 'name').map { |t| [t.name, t.id] })
end

@ -1,8 +1,11 @@
class CostQuery::Filter::CostTypeId < CostQuery::Filter::Base
label Issue.human_attribute_name(:cost_type)
extra_options :display
selectable false
def self.label
Issue.human_attribute_name(:cost_type)
end
def initialize(child = nil, options = {})
super
@display = options[:display]

@ -1,5 +1,8 @@
class CostQuery::Filter::CreatedOn < CostQuery::Filter::Base
db_field "entries.created_on"
use :time_operators
label Issue.human_attribute_name(:created_on)
def self.label
Issue.human_attribute_name(:created_on)
end
end

@ -2,5 +2,8 @@ class CostQuery::Filter::DueDate < CostQuery::Filter::Base
use :time_operators
join_table Issue
applies_for :label_issue_attributes
label Issue.human_attribute_name(:due_date)
def self.label
Issue.human_attribute_name(:due_date)
end
end

@ -2,7 +2,10 @@ class CostQuery::Filter::FixedVersionId < CostQuery::Filter::Base
use :null_operators
join_table Issue
applies_for :label_issue_attributes
label Issue.human_attribute_name(:fixed_version)
def self.label
Issue.human_attribute_name(:fixed_version)
end
def self.available_values(*)
versions = Version.find :all, :conditions => {:project_id => Project.visible.map{|p| p.id}}

@ -1,5 +1,8 @@
class CostQuery::Filter::IssueId < CostQuery::Filter::Base
label Issue.model_name.human
def self.label
Issue.model_name.human
end
def self.available_values(*)
issues = Project.visible.collect { |p| p.issues }.flatten.uniq.sort_by { |i| i.id }

@ -1,5 +1,8 @@
class CostQuery::Filter::OverriddenCosts < CostQuery::Filter::Base
label CostEntry.human_attribute_name(:overridden_costs)
def self.label
CostEntry.human_attribute_name(:overridden_costs)
end
def self.available_operators
['y', 'n'].map { |s| s.to_operator }

@ -1,7 +1,10 @@
class CostQuery::Filter::PriorityId < CostQuery::Filter::Base
join_table Issue
applies_for :label_issue_attributes
label Issue.human_attribute_name(:priority)
def self.label
Issue.human_attribute_name(:priority)
end
def self.available_values(*)
IssuePriority.find(:all, :order => 'position DESC').map { |i| [i.name, i.id] }

@ -1,6 +1,9 @@
class CostQuery::Filter::ProjectId < CostQuery::Filter::Base
db_field "entries.project_id"
label Project.model_name.human
def self.label
Project.model_name.human
end
def self.available_operators
["=", "!", "=_child_projects", "!_child_projects"].map { |s| s.to_operator }

@ -1,4 +1,7 @@
class CostQuery::Filter::SpentOn < CostQuery::Filter::Base
use :time_operators
label I18n.t(:label_spent_on_reporting)
def self.label
I18n.t(:label_spent_on_reporting)
end
end

@ -2,5 +2,8 @@ class CostQuery::Filter::StartDate < CostQuery::Filter::Base
use :time_operators
join_table Issue
applies_for :label_issue_attributes
label Issue.human_attribute_name(:start_date)
def self.label
Issue.human_attribute_name(:start_date)
end
end

@ -4,7 +4,10 @@ class CostQuery::Filter::StatusId < CostQuery::Filter::Base
available_operators 'c', 'o'
join_table Issue, IssueStatus => [Issue, :status]
applies_for :label_issue_attributes
label Issue.human_attribute_name(:status)
def self.label
Issue.human_attribute_name(:status)
end
def self.available_values(*)
IssueStatus.find(:all, :order => 'name').map { |i| [i.name, i.id] }

@ -2,5 +2,8 @@ class CostQuery::Filter::Subject < CostQuery::Filter::Base
use :string_operators
join_table Issue
applies_for :label_issue_attributes
label Issue.human_attribute_name(:subject)
def self.label
Issue.human_attribute_name(:subject)
end
end

@ -1,6 +1,9 @@
class CostQuery::Filter::Tmonth < CostQuery::Filter::Base
use :integer_operators
label I18n.t(:label_month_reporting)
def self.label
I18n.t(:label_month_reporting)
end
def self.available_values(*)
1.upto(12).map {|i| [ ::I18n.t('date.month_names')[i], i ]}

@ -1,7 +1,10 @@
class CostQuery::Filter::TrackerId < CostQuery::Filter::Base
join_table Issue
applies_for :label_issue_attributes
label Issue.human_attribute_name(:tracker)
def self.label
Issue.human_attribute_name(:tracker)
end
def self.available_values(*)
Tracker.find(:all, :order => 'name').map { |i| [i.name, i.id] }

@ -1,6 +1,9 @@
class CostQuery::Filter::Tweek < CostQuery::Filter::Base
use :integer_operators
label I18n.t(:label_week_reporting)
def self.label
I18n.t(:label_week_reporting)
end
def self.available_values(*)
1.upto(53).map {|i| [ i.to_s, i ]}

@ -1,6 +1,9 @@
class CostQuery::Filter::Tyear < CostQuery::Filter::Base
use :integer_operators
label I18n.t(:label_year_reporting)
def self.label
I18n.t(:label_year_reporting)
end
def self.available_values(*)
1970.upto(Date.today.year).map {|i| [ i.to_s, i ]}.reverse

@ -1,5 +1,8 @@
class CostQuery::Filter::UpdatedOn < CostQuery::Filter::Base
db_field "entries.updated_on"
use :time_operators
label Issue.human_attribute_name(:updated_on)
def self.label
Issue.human_attribute_name(:updated_on)
end
end

@ -1,5 +1,7 @@
class CostQuery::Filter::UserId < CostQuery::Filter::Base
label Issue.human_attribute_name(:user)
def self.label
Issue.human_attribute_name(:user)
end
def self.available_values(*)
users = Project.visible.collect {|p| p.users}.flatten.uniq.sort

@ -1,5 +1,8 @@
class CostQuery::GroupBy
class ActivityId < Base
label TimeEntry.human_attribute_name(:activity)
def self.label
TimeEntry.human_attribute_name(:activity)
end
end
end

@ -2,6 +2,9 @@ class CostQuery::GroupBy
class AssignedToId < Base
join_table Issue
applies_for :label_issue_attributes
label Issue.human_attribute_name(:assigned_to)
def self.label
Issue.human_attribute_name(:assigned_to)
end
end
end

@ -2,6 +2,9 @@ class CostQuery::GroupBy
class AuthorId < Base
join_table Issue
applies_for :label_issue_attributes
label Issue.human_attribute_name(:author)
def self.label
Issue.human_attribute_name(:author)
end
end
end

@ -2,6 +2,9 @@ class CostQuery::GroupBy
class CategoryId < Base
join_table Issue
applies_for :label_issue_attributes
label Issue.human_attribute_name(:category)
def self.label
Issue.human_attribute_name(:category)
end
end
end

@ -2,6 +2,9 @@ class CostQuery::GroupBy
class CostObjectId < Base
join_table Issue
applies_for :label_issue_attributes
label CostObject.model_name.human
def self.label
CostObject.model_name.human
end
end
end

@ -1,5 +1,8 @@
class CostQuery::GroupBy
class CostTypeId < Base
label CostType.model_name.human
def self.label
CostType.model_name.human
end
end
end

@ -2,6 +2,9 @@ class CostQuery::GroupBy
class FixedVersionId < Base
join_table Issue
applies_for :label_issue_attributes
label Issue.human_attribute_name(:fixed_version)
def self.label
Issue.human_attribute_name(:fixed_version)
end
end
end

@ -1,5 +1,8 @@
class CostQuery::GroupBy
class IssueId < Base
label Issue.model_name.human
def self.label
Issue.model_name.human
end
end
end

@ -2,6 +2,9 @@ class CostQuery::GroupBy
class PriorityId < Base
join_table Issue
applies_for :label_issue_attributes
label Issue.human_attribute_name(:priority)
def self.label
Issue.human_attribute_name(:priority)
end
end
end

@ -1,5 +1,8 @@
class CostQuery::GroupBy
class ProjectId < Base
label Project.model_name.human
def self.label
Project.model_name.human
end
end
end

@ -1,5 +1,8 @@
class CostQuery::GroupBy
class SpentOn < Base
label I18n.t(:label_spent_on_reporting)
def self.label
I18n.t(:label_spent_on_reporting)
end
end
end

@ -2,6 +2,9 @@ class CostQuery::GroupBy
class StatusId < Base
join_table Issue
applies_for :label_issue_attributes
label Issue.human_attribute_name(:status)
def self.label
Issue.human_attribute_name(:status)
end
end
end

@ -1,5 +1,8 @@
class CostQuery::GroupBy
class Tmonth < Base
label I18n.t(:label_month_reporting)
def self.label
I18n.t(:label_month_reporting)
end
end
end

@ -2,6 +2,9 @@ class CostQuery::GroupBy
class TrackerId < Base
join_table Issue
applies_for :label_issue_attributes
label Issue.human_attribute_name(:tracker)
def self.label
Issue.human_attribute_name(:tracker)
end
end
end

@ -1,5 +1,8 @@
class CostQuery::GroupBy
class Tweek < Base
label I18n.t(:label_week_reporting)
def self.label
I18n.t(:label_week_reporting)
end
end
end

@ -1,5 +1,8 @@
class CostQuery::GroupBy
class Tyear < Base
label I18n.t(:label_year_reporting)
def self.label
I18n.t(:label_year_reporting)
end
end
end

@ -1,5 +1,8 @@
class CostQuery::GroupBy
class UserId < Base
label Issue.human_attribute_name(:user)
def self.label
Issue.human_attribute_name(:user)
end
end
end

@ -1,5 +1,8 @@
class CostQuery::GroupBy
class Week < Base
label I18n.t(:label_week_reporting)
def self.label
I18n.t(:label_week_reporting)
end
end
end

@ -1,6 +1,6 @@
class CostQuery::Operator < Report::Operator
# Operators from Redmine
new "c", :arity => 0, :label => I18n.t(:label_closed) do
new "c", :arity => 0, :label => :label_closed do
def modify(query, field, *values)
raise "wrong field" if field.to_s.split('.').last != "status_id"
query.where "(#{IssueStatus.table_name}.is_closed = #{quoted_true})"
@ -16,7 +16,7 @@ class CostQuery::Operator < Report::Operator
end
end
new "=_child_projects", :validate => :integers, :label => I18n.t(:label_is_project_with_subprojects) do
new "=_child_projects", :validate => :integers, :label => :label_is_project_with_subprojects do
def modify(query, field, *values)
p_ids = []
values.each do |value|
@ -28,7 +28,7 @@ class CostQuery::Operator < Report::Operator
end
end
new "!_child_projects", :validate => :integers, :label => I18n.t(:label_is_not_project_with_subprojects) do
new "!_child_projects", :validate => :integers, :label => :label_is_not_project_with_subprojects do
def modify(query, field, *values)
p_ids = []
values.each do |value|

Loading…
Cancel
Save