OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add globalid behavior
Klaus Zandersb53e25d171b0
diff --git a/Gemfile b/Gemfileindex cc4951b27a2..9583faa751b 100644--- a/Gemfile+++ b/Gemfile@@ -173,6 +173,9 @@ gem "paper_trail", "~> 16.0.0"gem "op-clamav-client", "~> 3.4", require: "clamav"+# Global ID for polymorphic associations+gem "globalid", "~> 1.2"+# Recurring meeting events definitiongem "ice_cube", "~> 0.17.0"diff --git a/Gemfile.lock b/Gemfile.lockindex b26ebc918e1..47c4c2fca76 100644--- a/Gemfile.lock+++ b/Gemfile.lock@@ -1399,6 +1399,7 @@ DEPENDENCIESfog-awsfriendly_id (~> 5.5.0)fuubar (~> 2.5.0)+ globalid (~> 1.2)gon (~> 6.4.0)good_job (= 3.99.1)google-apis-gmail_v1diff --git a/modules/costs/app/models/time_entry.rb b/modules/costs/app/models/time_entry.rbindex 325c4d5977c..e5de0f3c379 100644--- a/modules/costs/app/models/time_entry.rb+++ b/modules/costs/app/models/time_entry.rb@@ -48,7 +48,7 @@ class TimeEntry < ApplicationRecordacts_as_journalized- validates :user_id, :project_id, :spent_on,+ validates :user_id, :project_id, :spent_on, :entity,presence: truevalidates :hours,@@ -128,8 +128,16 @@ class TimeEntry < ApplicationRecordself.entity = valueend+ def entity=(value)+ if value.is_a?(String) && value.starts_with?("gid://")+ super(GlobalID::Locator.locate(value, only: ALLOWED_ENTITY_TYPES.map(&:constantize)))+ else+ super+ end+ end+def hours=(value)- write_attribute :hours, (value.is_a?(String) ? (value.to_hours || value) : value)+ super(value.is_a?(String) ? (value.to_hours || value) : value)enddef ongoing_hoursdiff --git a/modules/costs/config/locales/en.yml b/modules/costs/config/locales/en.ymlindex 707aef6fae1..3661f8e2536 100644--- a/modules/costs/config/locales/en.yml+++ b/modules/costs/config/locales/en.yml@@ -58,6 +58,7 @@ en:time_entry:project: Projectuser: User+ entity: Entitywork_package: Work packagesubject: Subjecthours: Hours