Skip to content

Commit e028374

Browse files
authored
Merge pull request #11450 from alphagov/configurable-taxons
Make "requires_taxon?" a StandardEdition configurable thing [WHIT-3341]
2 parents 8f877d2 + 079a2ea commit e028374

16 files changed

Lines changed: 55 additions & 2 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module StandardEdition::Taxon
2+
extend ActiveSupport::Concern
3+
4+
def requires_taxon?
5+
type_instance.settings["taxon_required"]
6+
end
7+
end

app/models/configurable_document_types/case_study.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
"organisations": null,
111111
"backdating_enabled": true,
112112
"history_mode_enabled": true,
113+
"taxon_required": true,
113114
"translations_enabled": true
114115
}
115116
}

app/models/configurable_document_types/government_response.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126
"organisations": null,
127127
"backdating_enabled": true,
128128
"history_mode_enabled": true,
129+
"taxon_required": true,
129130
"translations_enabled": true
130131
}
131132
}

app/models/configurable_document_types/history_page.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
"backdating_enabled": false,
8989
"history_mode_enabled": false,
9090
"file_attachments_enabled": false,
91+
"taxon_required": true,
9192
"translations_enabled": false
9293
}
9394
}

app/models/configurable_document_types/news_story.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126
"organisations": null,
127127
"backdating_enabled": true,
128128
"history_mode_enabled": true,
129+
"taxon_required": true,
129130
"translations_enabled": true
130131
}
131132
}

app/models/configurable_document_types/press_release.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126
"organisations": null,
127127
"backdating_enabled": true,
128128
"history_mode_enabled": true,
129+
"taxon_required": true,
129130
"translations_enabled": true
130131
}
131132
}

app/models/configurable_document_types/topical_event.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@
199199
"organisations": null,
200200
"backdating_enabled": false,
201201
"history_mode_enabled": false,
202+
"taxon_required": true,
202203
"translations_enabled": false
203204
}
204205
}

app/models/configurable_document_types/world_news_story.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
"organisations": null,
112112
"backdating_enabled": true,
113113
"history_mode_enabled": true,
114+
"taxon_required": true,
114115
"translations_enabled": true
115116
}
116117
}

app/models/edition.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Edition < ApplicationRecord
6060
validates_with LinkCheckReportValidator, on: :publish # TODO: make this a configurable StandardEdition property
6161
validates_with InternalPathLinksValidator, attribute: :body, on: :publish # TODO: make this a configurable StandardEdition property
6262
validates_with GovspeakContactEmbedValidator, attribute: :body, on: :publish, unless: ->(record) { record.is_a?(StandardEdition) }
63-
validates_with TaxonValidator, on: :publish, if: :requires_taxon? # TODO: make this a configurable StandardEdition property
63+
validates_with TaxonValidator, on: :publish, if: :requires_taxon?
6464

6565
validates :creator, presence: true
6666
validates :title, presence: true, if: :title_required?, length: { maximum: 255 }

app/models/standard_edition.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class StandardEdition < Edition
1111
include Edition::WorldwideOrganisations
1212
include HasBlockContent
1313
include StandardEdition::LeadImage
14+
include StandardEdition::Taxon
1415

1516
FEATURED_DOCUMENTS_DISPLAY_LIMIT = 6
1617

0 commit comments

Comments
 (0)