govuk_content_models 45.0.0 → 46.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +2 -4
- data/app/models/artefact.rb +0 -42
- data/app/validators/slug_validator.rb +0 -35
- data/lib/govuk_content_models/test_helpers/factories.rb +0 -10
- data/lib/govuk_content_models/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6df8bc4ddc5049746a2b20c17f061238c379e8f
|
4
|
+
data.tar.gz: 29cab662f67c67bf0ea7dd06a970a1c1eb5b7891
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3333530c567b4f52f6e8dd8faaed4066e59791ba22f9ddd4ec5b94e8f7470907f8eb75ed2eb0e7b709db24525c7d81d4378de3254fb4de9d7fd29d1d13057982
|
7
|
+
data.tar.gz: 280fd6e51851c234c972d5c826d9ee9bb0e2877519035fc9f5a6ef2dbec5e22a7772da1851b84f0216a85c38f9868a4c950aa7a889ed7c2530188dbce60ffae2
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# GOV.UK Content Models
|
2
2
|
|
3
|
-
A gem containing the shared models for the old GOV.UK
|
4
|
-
|
5
|
-
- [Publisher](https://github.com/alphagov/publisher)
|
6
|
-
- [Content API](https://github.com/alphagov/govuk_content_api)
|
3
|
+
A gem containing the shared models for the old GOV.UK [Publisher][publisher] application.
|
7
4
|
|
5
|
+
[Publisher]: https://github.com/alphagov/publisher
|
data/app/models/artefact.rb
CHANGED
@@ -74,48 +74,6 @@ class Artefact
|
|
74
74
|
"specialist-publisher" => ["manual"],
|
75
75
|
"finder-api" => ["finder",
|
76
76
|
"finder_email_signup"],
|
77
|
-
"whitehall" => ["announcement",
|
78
|
-
"authored_article",
|
79
|
-
"case_study",
|
80
|
-
"consultation",
|
81
|
-
"corporate_information_page",
|
82
|
-
"corporate_report",
|
83
|
-
"correspondence",
|
84
|
-
"decision",
|
85
|
-
"detailed_guide",
|
86
|
-
"document_collection",
|
87
|
-
"draft_text",
|
88
|
-
"fatality_notice",
|
89
|
-
"foi_release",
|
90
|
-
"form",
|
91
|
-
"government_response",
|
92
|
-
"guidance",
|
93
|
-
"impact_assessment",
|
94
|
-
"independent_report",
|
95
|
-
"international_treaty",
|
96
|
-
"map",
|
97
|
-
"national_statistics",
|
98
|
-
"news_story",
|
99
|
-
"notice",
|
100
|
-
"official_statistics",
|
101
|
-
"oral_statement",
|
102
|
-
"policy",
|
103
|
-
"policy_paper",
|
104
|
-
"press_release",
|
105
|
-
"promotional",
|
106
|
-
"publication",
|
107
|
-
"regulation",
|
108
|
-
"research",
|
109
|
-
"speaking_notes",
|
110
|
-
"statistical_data_set",
|
111
|
-
"statistics",
|
112
|
-
"statutory_guidance",
|
113
|
-
"supporting_page",
|
114
|
-
"transcript",
|
115
|
-
"transparency",
|
116
|
-
"world_location_news_article",
|
117
|
-
"worldwide_priority",
|
118
|
-
"written_statement"],
|
119
77
|
}.freeze
|
120
78
|
|
121
79
|
RETIRED_FORMATS = %w[ business_support campaign programme video]
|
@@ -6,9 +6,7 @@ class SlugValidator < ActiveModel::EachValidator
|
|
6
6
|
ForeignTravelAdvicePageValidator,
|
7
7
|
HelpPageValidator,
|
8
8
|
FinderEmailSignupValidator,
|
9
|
-
GovernmentPageValidator,
|
10
9
|
ManualPageValidator,
|
11
|
-
DetailedGuideValidator,
|
12
10
|
DefaultValidator
|
13
11
|
].map { |klass| klass.new(record, attribute, value) }
|
14
12
|
|
@@ -93,29 +91,6 @@ protected
|
|
93
91
|
end
|
94
92
|
end
|
95
93
|
|
96
|
-
class GovernmentPageValidator < InstanceValidator
|
97
|
-
def url_parts
|
98
|
-
# Some inside govt slugs have a . in them (eg news articles with no english translation)
|
99
|
-
super.map {|part| part.gsub(/\./, '') }
|
100
|
-
end
|
101
|
-
|
102
|
-
def applicable?
|
103
|
-
record.respond_to?(:kind) && prefixed_whitehall_format_names.include?(record.kind)
|
104
|
-
end
|
105
|
-
|
106
|
-
def validate!
|
107
|
-
record.errors[attribute] << "Inside Government slugs must have a government/ prefix" unless starts_with?('government/')
|
108
|
-
unless url_parts.all? { |url_part| valid_slug?(url_part) }
|
109
|
-
record.errors[attribute] << "must be usable in a URL"
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
protected
|
114
|
-
def prefixed_whitehall_format_names
|
115
|
-
Artefact::FORMATS_BY_DEFAULT_OWNING_APP["whitehall"] - ["detailed_guide"]
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
94
|
class ManualPageValidator < InstanceValidator
|
120
95
|
def applicable?
|
121
96
|
of_kind?('manual')
|
@@ -147,16 +122,6 @@ protected
|
|
147
122
|
end
|
148
123
|
end
|
149
124
|
|
150
|
-
class DetailedGuideValidator < InstanceValidator
|
151
|
-
def applicable?
|
152
|
-
of_kind?('detailed_guide')
|
153
|
-
end
|
154
|
-
|
155
|
-
def validate!
|
156
|
-
record.errors[attribute] << "must be a valid URL either at the root or under 'guidance/'" unless value.match(%r{^(guidance/)?[a-z0-9\-_]+$})
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
125
|
class DefaultValidator < InstanceValidator
|
161
126
|
def applicable?
|
162
127
|
true
|
@@ -32,12 +32,6 @@ FactoryGirl.define do
|
|
32
32
|
owning_app 'publisher'
|
33
33
|
content_id { SecureRandom.uuid }
|
34
34
|
|
35
|
-
trait :whitehall do
|
36
|
-
sequence(:slug) {|n| "government/slug--#{n}"}
|
37
|
-
owning_app "whitehall"
|
38
|
-
kind Artefact::FORMATS_BY_DEFAULT_OWNING_APP["whitehall"].first
|
39
|
-
end
|
40
|
-
|
41
35
|
trait :with_published_edition do
|
42
36
|
after(:create) {|object|
|
43
37
|
self.create("#{object.kind}_edition".to_sym, panopticon_id: object.id, slug: object.slug, state: "published")
|
@@ -67,10 +61,6 @@ FactoryGirl.define do
|
|
67
61
|
|
68
62
|
factory :live_artefact_with_edition, traits: [:live, :with_published_edition]
|
69
63
|
|
70
|
-
factory :whitehall_draft_artefact, traits: [:whitehall, :draft]
|
71
|
-
factory :whitehall_live_artefact, traits: [:whitehall, :live]
|
72
|
-
factory :whitehall_archived_artefact, traits: [:whitehall, :archived]
|
73
|
-
|
74
64
|
factory :non_publisher_artefact, traits: [:non_publisher]
|
75
65
|
end
|
76
66
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_content_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 46.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Battley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05
|
11
|
+
date: 2017-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bson_ext
|