summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/models/issue.rb6
-rw-r--r--app/models/time_entry.rb14
2 files changed, 6 insertions, 14 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb
index d6eab02fe..8082e43b7 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -93,7 +93,11 @@ class Issue < ActiveRecord::Base
self.priority = nil
write_attribute(:priority_id, pid)
end
-
+
+ def estimated_hours=(h)
+ write_attribute :estimated_hours, (h.is_a?(String) ? h.to_hours : h)
+ end
+
def validate
if self.due_date.nil? && @attributes['due_date'] && !@attributes['due_date'].empty?
errors.add :due_date, :activerecord_error_not_a_date
diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb
index 0dce253c7..ddaff2b60 100644
--- a/app/models/time_entry.rb
+++ b/app/models/time_entry.rb
@@ -40,19 +40,7 @@ class TimeEntry < ActiveRecord::Base
end
def hours=(h)
- s = h.dup
- if s.is_a?(String)
- s.strip!
- unless s =~ %r{^[\d\.,]+$}
- # 2:30 => 2.5
- s.gsub!(%r{^(\d+):(\d+)$}) { $1.to_i + $2.to_i / 60.0 }
- # 2h30, 2h, 30m
- s.gsub!(%r{^((\d+)\s*(h|hours?))?\s*((\d+)\s*(m|min)?)?$}) { |m| ($1 || $4) ? ($2.to_i + $5.to_i / 60.0) : m[0] }
- end
- # 2,5 => 2.5
- s.gsub!(',', '.')
- end
- write_attribute :hours, s
+ write_attribute :hours, (h.is_a?(String) ? h.to_hours : h)
end
# tyear, tmonth, tweek assigned where setting spent_on attributes