File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -48,10 +48,6 @@ def process_associations_after_save(edition)
4848 schedule_republishing_workers
4949 end
5050
51- def self . base_path
52- "/government/calls-for-evidence/"
53- end
54-
5551 def schedule_republishing_workers
5652 if opening_at . try ( :future? )
5753 PublishingApiDocumentRepublishingWorker
@@ -135,6 +131,10 @@ def string_for_slug
135131 title
136132 end
137133
134+ def base_path
135+ "/government/calls-for-evidence/#{ slug } "
136+ end
137+
138138 def publishing_api_presenter
139139 PublishingApi ::CallForEvidencePresenter
140140 end
Original file line number Diff line number Diff line change @@ -10,10 +10,6 @@ class CaseStudy < Edition
1010 include Edition ::WorldwideOrganisations
1111 include Edition ::LeadImage
1212
13- def self . base_path
14- "/government/case-studies/"
15- end
16-
1713 def rendering_app
1814 Whitehall ::RenderingApp ::FRONTEND
1915 end
@@ -22,6 +18,10 @@ def translatable?
2218 !non_english_edition?
2319 end
2420
21+ def base_path
22+ "/government/case-studies/#{ slug } "
23+ end
24+
2525 def publishing_api_presenter
2626 PublishingApi ::CaseStudyPresenter
2727 end
Original file line number Diff line number Diff line change @@ -58,10 +58,6 @@ def process_associations_after_save(edition)
5858 schedule_republishing_workers
5959 end
6060
61- def self . base_path
62- "/government/consultations/"
63- end
64-
6561 def schedule_republishing_workers
6662 if opening_at . try ( :future? )
6763 PublishingApiDocumentRepublishingWorker
@@ -149,6 +145,10 @@ def string_for_slug
149145 title
150146 end
151147
148+ def base_path
149+ "/government/consultations/#{ slug } "
150+ end
151+
152152 def publishing_api_presenter
153153 PublishingApi ::ConsultationPresenter
154154 end
Original file line number Diff line number Diff line change @@ -11,10 +11,6 @@ class DetailedGuide < Edition
1111 include Edition ::RelatedDocuments
1212 include Edition ::TopicalEvents
1313
14- def self . base_path
15- "/guidance/"
16- end
17-
1814 has_many :related_mainstreams , foreign_key : "edition_id" , dependent : :destroy
1915
2016 validate :related_mainstream_found , if : :related_mainstream_requested?
@@ -108,6 +104,10 @@ def all_nation_applicability_selected?
108104 newly_created ? false : all_nation_applicability
109105 end
110106
107+ def base_path
108+ "/guidance/#{ slug } "
109+ end
110+
111111 def publishing_api_presenter
112112 PublishingApi ::DetailedGuidePresenter
113113 end
Original file line number Diff line number Diff line change @@ -86,8 +86,10 @@ def first_edition_id
8686 def similar_slug_exists?
8787 scope = Document . where ( document_type :)
8888
89- # return false if slug.nil?
90- return false if slug_without_sequence . blank?
89+ # slug is a nullable column, so we can't assume that it exists
90+ return false if slug . nil?
91+
92+ slug_without_sequence = slug . split ( sequence_separator ) . first
9193
9294 scope . where (
9395 "slug IN (?) OR slug LIKE ?" ,
@@ -96,13 +98,6 @@ def similar_slug_exists?
9698 ) . count > 1
9799 end
98100
99- def slug_without_sequence
100- # slug is a nullable column, so we can't assume that it exists
101- return if slug . nil?
102-
103- slug . split ( sequence_separator ) . first
104- end
105-
106101 delegate :sequence_separator , to : :friendly_id_config
107102
108103 def should_generate_new_friendly_id?
Original file line number Diff line number Diff line change @@ -22,10 +22,6 @@ def process_associations_before_save(new_edition)
2222
2323 add_trait ClonesGroupsTrait
2424
25- def self . base_path
26- "/government/collections/"
27- end
28-
2925 def rendering_app
3026 Whitehall ::RenderingApp ::FRONTEND
3127 end
@@ -38,6 +34,10 @@ def locale_can_be_changed?
3834 true
3935 end
4036
37+ def base_path
38+ "/government/collections/#{ slug } "
39+ end
40+
4141 def publishing_api_presenter
4242 PublishingApi ::DocumentCollectionPresenter
4343 end
Original file line number Diff line number Diff line change @@ -101,10 +101,6 @@ def self.scheduled_for_publication_as(slug)
101101 document &.scheduled_edition
102102 end
103103
104- def self . base_path
105- "/government/generic-editions/"
106- end
107-
108104 def skip_main_validation?
109105 FROZEN_STATES . include? ( state )
110106 end
@@ -400,10 +396,13 @@ def attribute_names
400396 end
401397
402398 def base_path
403- "#{ self . class . base_path } #{ url_slug } "
399+ url_slug = slug || id . to_param
400+ "/government/generic-editions/#{ url_slug } "
404401 end
405402
406- delegate :slug_without_sequence , to : :document
403+ def base_path_without_sequence
404+ base_path . split ( document . sequence_separator ) . first
405+ end
407406
408407 def public_path ( options = { } )
409408 return if base_path . nil?
@@ -447,10 +446,6 @@ def deleted_associated_documents
447446
448447private
449448
450- def url_slug
451- slug || id . to_param
452- end
453-
454449 def date_for_government
455450 published_edition_date = first_public_at . try ( :to_date )
456451 draft_edition_date = updated_at . try ( :to_date )
Original file line number Diff line number Diff line change @@ -25,10 +25,6 @@ def process_associations_after_save(new_edition)
2525
2626 add_trait CasualtiesTrait
2727
28- def self . base_path
29- "/government/fatalities/"
30- end
31-
3228 def has_operational_field?
3329 true
3430 end
@@ -37,6 +33,10 @@ def rendering_app
3733 Whitehall ::RenderingApp ::FRONTEND
3834 end
3935
36+ def base_path
37+ "/government/fatalities/#{ slug } "
38+ end
39+
4040 def publishing_api_presenter
4141 PublishingApi ::FatalityNoticePresenter
4242 end
Original file line number Diff line number Diff line change @@ -69,8 +69,8 @@ def self.save_draft_translation(
6969
7070 content . merge! ( bulk_publishing : true ) if bulk_publishing
7171
72- base_path = if model_instance . respond_to? ( :slug_without_sequence )
73- " #{ model_instance . class . base_path } #{ model_instance . slug_without_sequence } "
72+ base_path = if model_instance . respond_to? ( :base_path_without_sequence )
73+ model_instance . base_path_without_sequence
7474 else
7575 content [ :base_path ]
7676 end
You can’t perform that action at this time.
0 commit comments