summaryrefslogtreecommitdiff
path: root/app/models/node.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/node.rb')
-rw-r--r--app/models/node.rb22
1 files changed, 2 insertions, 20 deletions
diff --git a/app/models/node.rb b/app/models/node.rb
index 5c28a786..f5b76b45 100644
--- a/app/models/node.rb
+++ b/app/models/node.rb
@@ -42,9 +42,6 @@ class Node < ApplicationRecord
42 :inclusion => { :in => ->(_) { Page.custom_templates } }, 42 :inclusion => { :in => ->(_) { Page.custom_templates } },
43 :allow_blank => true, 43 :allow_blank => true,
44 :if => :default_template_name_changed? 44 :if => :default_template_name_changed?
45 validates :external_url, :format => { :with => %r{\Ahttps?://}i,
46 :allow_blank => true,
47 :message => :must_be_http }
48 45
49 # Everything outside the Trash subtree, the Trash node included. 46 # Everything outside the Trash subtree, the Trash node included.
50 # Relies on unique_name being authoritative for tree position -- 47 # Relies on unique_name being authoritative for tree position --
@@ -260,6 +257,8 @@ class Node < ApplicationRecord
260 self.slug = self.head.slug 257 self.slug = self.head.slug
261 end 258 end
262 259
260 self.external_url = self.head.external_url
261
263 if self.head.parent_node_id && self.head.parent_node_id != parent_id 262 if self.head.parent_node_id && self.head.parent_node_id != parent_id
264 new_parent = Node.find_by(:id => self.head.parent_node_id) 263 new_parent = Node.find_by(:id => self.head.parent_node_id)
265 264
@@ -604,23 +603,6 @@ class Node < ApplicationRecord
604 self.created_at < new_id_format_date ? unique_path : id 603 self.created_at < new_id_format_date ? unique_path : id
605 end 604 end
606 605
607 def update_external_url!(url, current_user = nil)
608 normalised = url.presence
609 return false if normalised == external_url
610
611 guard_live_change!(current_user)
612 previous = external_url
613
614 transaction do
615 update!(:external_url => normalised)
616 NodeAction.record!(:node => self, :user => current_user,
617 :action => "node_external_url",
618 :path => unique_name,
619 :external_url => { "from" => previous, "to" => normalised })
620 end
621 true
622 end
623
624 # Full-text search across all locale translations using PostgreSQL tsvector. 606 # Full-text search across all locale translations using PostgreSQL tsvector.
625 # Uses 'simple' dictionary (no stemming, no stopwords) so queries work 607 # Uses 'simple' dictionary (no stemming, no stopwords) so queries work
626 # across German and English content without language detection. 608 # across German and English content without language detection.