]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/3470'
authorTom Hughes <tom@compton.nu>
Wed, 23 Feb 2022 20:38:21 +0000 (20:38 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 23 Feb 2022 20:38:21 +0000 (20:38 +0000)
app/models/access_token.rb
app/models/client_application.rb
app/models/issue.rb
app/models/note_comment.rb
app/models/oauth_token.rb
app/models/old_node.rb
app/models/old_relation.rb
app/models/old_way.rb
app/models/trace.rb
app/models/user_block.rb
config/application.rb

index 1a5ff8553c825a785ee5fff21fa1aa42dcae618c..53590a5946461c89e13dc22bc69b4a945a8cc94b 100644 (file)
@@ -36,8 +36,8 @@
 #
 
 class AccessToken < OauthToken
-  belongs_to :user
-  belongs_to :client_application
+  belongs_to :user, :optional => true
+  belongs_to :client_application, :optional => true
 
   scope :valid, -> { where(:invalidated_at => nil) }
 
index 1b2faafbb1d79c96b63da5303bf20f0ba8ae785b..d9d6b2df8ca60d11ecfe404d1bc6ef94cfe7178f 100644 (file)
@@ -31,7 +31,7 @@
 #
 
 class ClientApplication < ApplicationRecord
-  belongs_to :user
+  belongs_to :user, :optional => true
   has_many :tokens, :class_name => "OauthToken", :dependent => :delete_all
   has_many :access_tokens
   has_many :oauth2_verifiers
index c94fe56a7d47b30c33f9ac3d51cfe6c1bee81afd..207af63c4b1481ad79179d671c390cd9b3d178e5 100644 (file)
@@ -32,9 +32,9 @@
 
 class Issue < ApplicationRecord
   belongs_to :reportable, :polymorphic => true
-  belongs_to :reported_user, :class_name => "User"
-  belongs_to :user_resolved, :class_name => "User", :foreign_key => :resolved_by
-  belongs_to :user_updated, :class_name => "User", :foreign_key => :updated_by
+  belongs_to :reported_user, :class_name => "User", :optional => true
+  belongs_to :user_resolved, :class_name => "User", :foreign_key => :resolved_by, :optional => true
+  belongs_to :user_updated, :class_name => "User", :foreign_key => :updated_by, :optional => true
 
   has_many :reports, :dependent => :destroy
   has_many :comments, :class_name => "IssueComment", :dependent => :destroy
index eed917eee3c868d2bf6ec19deb258c4481bc54f7..999d045075f2f033bfc2a4e0ab9e8d83b296000a 100644 (file)
@@ -25,7 +25,7 @@
 
 class NoteComment < ApplicationRecord
   belongs_to :note, :touch => true
-  belongs_to :author, :class_name => "User"
+  belongs_to :author, :class_name => "User", :optional => true
 
   validates :id, :uniqueness => true, :presence => { :on => :update },
                  :numericality => { :on => :update, :only_integer => true }
index affdcdeb815b45b3c6d6ad32bf9c6526064ee45b..b4519efe21642a0b60693e6279d2eeb32d59fde7 100644 (file)
@@ -36,8 +36,8 @@
 #
 
 class OauthToken < ApplicationRecord
-  belongs_to :client_application
-  belongs_to :user
+  belongs_to :client_application, :optional => true
+  belongs_to :user, :optional => true
 
   scope :authorized, -> { where("authorized_at IS NOT NULL and invalidated_at IS NULL") }
 
index 3caf0442b8d912fa15a7e014736bac8f6da28a31..3261c9a0e2875b58c8646169930d7381740ad41b 100644 (file)
@@ -46,7 +46,7 @@ class OldNode < ApplicationRecord
   validate :validate_position
 
   belongs_to :changeset
-  belongs_to :redaction
+  belongs_to :redaction, :optional => true
   belongs_to :current_node, :class_name => "Node", :foreign_key => "node_id"
 
   has_many :old_tags, :class_name => "OldNodeTag", :foreign_key => [:node_id, :version]
index 29edb90adbee10227fab1f6fdff38ec788e661ac..e948cae5ea6a70a3fd9c59572a487dc1e3532d89 100644 (file)
@@ -31,7 +31,7 @@ class OldRelation < ApplicationRecord
   include Redactable
 
   belongs_to :changeset
-  belongs_to :redaction
+  belongs_to :redaction, :optional => true
   belongs_to :current_relation, :class_name => "Relation", :foreign_key => "relation_id"
 
   has_many :old_members, -> { order(:sequence_id) }, :class_name => "OldRelationMember", :foreign_key => [:relation_id, :version]
index 7af8906b1a9a64b36ab371ab01b62e0411af146b..03c281e5a437c40f8f4aef0a8b5bcfaaf16bcdf2 100644 (file)
@@ -31,7 +31,7 @@ class OldWay < ApplicationRecord
   include Redactable
 
   belongs_to :changeset
-  belongs_to :redaction
+  belongs_to :redaction, :optional => true
   belongs_to :current_way, :class_name => "Way", :foreign_key => "way_id"
 
   has_many :old_nodes, :class_name => "OldWayNode", :foreign_key => [:way_id, :version]
index bdafdd9d5c9116f4340ddd0af108fa86abbf549a..feefc077387b9ca32ea05ad247c2184de992ae8d 100644 (file)
@@ -31,8 +31,8 @@ class Trace < ApplicationRecord
   self.table_name = "gpx_files"
 
   belongs_to :user, :counter_cache => true
-  has_many :tags, :class_name => "Tracetag", :foreign_key => "gpx_id", :dependent => :delete_all
-  has_many :points, :class_name => "Tracepoint", :foreign_key => "gpx_id", :dependent => :delete_all
+  has_many :tags, :class_name => "Tracetag", :foreign_key => "gpx_id", :dependent => :delete_all, :inverse_of => :trace
+  has_many :points, :class_name => "Tracepoint", :foreign_key => "gpx_id", :dependent => :delete_all, :inverse_of => :trace
 
   scope :visible, -> { where(:visible => true) }
   scope :visible_to, ->(u) { visible.where("visibility IN ('public', 'identifiable') OR user_id = ?", u) }
index 47ff9ff08abcb4359476f830da79fa714b2d344c..46a8c282b3c18ba8d3b10f9554fe54cde8a1f8ae 100644 (file)
@@ -30,7 +30,7 @@ class UserBlock < ApplicationRecord
 
   belongs_to :user, :class_name => "User"
   belongs_to :creator, :class_name => "User"
-  belongs_to :revoker, :class_name => "User"
+  belongs_to :revoker, :class_name => "User", :optional => true
 
   PERIODS = Settings.user_block_periods
 
index 7b576d38f835f30289ee8968d1bf070c99794a83..10a2372dbca005f2d1afbe5e3f0bc5caa6c0e395 100644 (file)
@@ -35,10 +35,6 @@ module OpenStreetMap
     # This has defaulted to false since rails 6.0
     config.action_view.default_enforce_utf8 = true
 
-    # This defaults to true from rails 5.0 but our code doesn't comply
-    # with it at all so we turn it off
-    config.active_record.belongs_to_required_by_default = false unless Settings.status == "database_offline"
-
     # Use SQL instead of Active Record's schema dumper when creating the database.
     # This is necessary if your schema can't be completely dumped by the schema dumper,
     # like if you have constraints or database-specific column types