govuk_content_models 7.2.1 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6,7 +6,7 @@ class SpecialistDocumentEdition
|
|
|
6
6
|
include Mongoid::Timestamps
|
|
7
7
|
include Workflow
|
|
8
8
|
|
|
9
|
-
field :
|
|
9
|
+
field :document_id, type: String
|
|
10
10
|
field :version_number, type: Integer, default: 1
|
|
11
11
|
field :sibling_in_progress, type: Integer, default: nil
|
|
12
12
|
field :business_proposition, type: Boolean, default: false
|
|
@@ -63,14 +63,11 @@ class SpecialistDocumentEdition
|
|
|
63
63
|
|
|
64
64
|
validates :title, presence: true
|
|
65
65
|
validates :version_number, presence: true
|
|
66
|
-
validates :
|
|
66
|
+
validates :document_id, presence: true
|
|
67
67
|
validates_with SafeHtml
|
|
68
68
|
|
|
69
|
-
before_save :check_for_archived_artefact
|
|
70
|
-
before_destroy :destroy_artefact
|
|
71
|
-
|
|
72
69
|
index "assigned_to_id"
|
|
73
|
-
index "
|
|
70
|
+
index "document_id"
|
|
74
71
|
index "state"
|
|
75
72
|
|
|
76
73
|
class << self; attr_accessor :fields_to_clone end
|
|
@@ -79,7 +76,7 @@ class SpecialistDocumentEdition
|
|
|
79
76
|
alias_method :admin_list_title, :title
|
|
80
77
|
|
|
81
78
|
def series
|
|
82
|
-
|
|
79
|
+
SpecialistDocumentEdition.where(document_id: document_id)
|
|
83
80
|
end
|
|
84
81
|
|
|
85
82
|
def history
|
|
@@ -269,35 +266,7 @@ class SpecialistDocumentEdition
|
|
|
269
266
|
self.save!
|
|
270
267
|
end
|
|
271
268
|
|
|
272
|
-
def check_for_archived_artefact
|
|
273
|
-
if panopticon_id
|
|
274
|
-
a = Artefact.find(panopticon_id)
|
|
275
|
-
if a.state == "archived" and changed_attributes.any?
|
|
276
|
-
# If we're only changing the state to archived, that's ok
|
|
277
|
-
# Any other changes are not allowed
|
|
278
|
-
allowed_keys = ["state", "updated_at"]
|
|
279
|
-
unless ((changed_attributes.keys - allowed_keys).empty?) and state == "archived"
|
|
280
|
-
raise "Editing of an edition with an Archived artefact is not allowed"
|
|
281
|
-
end
|
|
282
|
-
end
|
|
283
|
-
end
|
|
284
|
-
end
|
|
285
|
-
|
|
286
269
|
def artefact
|
|
287
270
|
Artefact.find(panopticon_id)
|
|
288
271
|
end
|
|
289
|
-
|
|
290
|
-
# When we delete an edition is the only one in its series
|
|
291
|
-
# we delete the associated artefact to remove all trace of the
|
|
292
|
-
# item from the system.
|
|
293
|
-
#
|
|
294
|
-
# We don't do this by notifying panopticon as this will only ever
|
|
295
|
-
# happen for artefacts representing editions that haven't been
|
|
296
|
-
# published (and therefore aren't registered in the rest of the)
|
|
297
|
-
# system.
|
|
298
|
-
def destroy_artefact
|
|
299
|
-
if can_destroy? && siblings.empty?
|
|
300
|
-
Artefact.find(self.panopticon_id).destroy
|
|
301
|
-
end
|
|
302
|
-
end
|
|
303
272
|
end
|
|
@@ -17,13 +17,12 @@ class SpecialistDocumentEditionTest < ActiveSupport::TestCase
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
should "be persistable" do
|
|
20
|
-
artefact = FactoryGirl.create(:artefact)
|
|
21
20
|
edition = SpecialistDocumentEdition.create!(
|
|
22
21
|
slug: 'cma-cases/merger-investigation-2014',
|
|
23
22
|
title: "Merger Investigation 2014",
|
|
24
23
|
summary: "This is the summary of stuff going on in the Merger Investigation 2014",
|
|
25
24
|
state: "published",
|
|
26
|
-
|
|
25
|
+
document_id: 'a-document-id'
|
|
27
26
|
)
|
|
28
27
|
|
|
29
28
|
found = SpecialistDocumentEdition.where(slug: edition.slug).first
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: govuk_content_models
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 7.
|
|
4
|
+
version: 7.3.0
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2014-02-
|
|
12
|
+
date: 2014-02-22 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: bson_ext
|
|
@@ -456,7 +456,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
456
456
|
version: '0'
|
|
457
457
|
segments:
|
|
458
458
|
- 0
|
|
459
|
-
hash:
|
|
459
|
+
hash: -2619611699370403934
|
|
460
460
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
461
461
|
none: false
|
|
462
462
|
requirements:
|
|
@@ -465,7 +465,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
465
465
|
version: '0'
|
|
466
466
|
segments:
|
|
467
467
|
- 0
|
|
468
|
-
hash:
|
|
468
|
+
hash: -2619611699370403934
|
|
469
469
|
requirements: []
|
|
470
470
|
rubyforge_project:
|
|
471
471
|
rubygems_version: 1.8.23
|