lib/scrivito/workspace.rb in scrivito_sdk-0.60.0 vs lib/scrivito/workspace.rb in scrivito_sdk-0.65.0.rc1
- old
+ new
@@ -77,11 +77,12 @@
# @return [Scrivito::Workspace]
def self.find_by_title(title)
all.detect { |workspace| workspace.title == title }
end
- delegate :content_state, :base_revision_id, :base_content_state, :uses_obj_classes, to: :data
+ delegate :content_state_id, :base_content_state_id, :content_state,
+ :base_revision_id, :base_content_state, :uses_obj_classes, to: :data
# Create a new workspace
# @api public
# @param [Hash] attributes
# @return [Scrivito::Workspace]
@@ -201,18 +202,17 @@
def outdated?
!published? && Workspace.published.revision.id != base_revision_id
end
def revision
- @revision ||= Revision.new(id: revision_id, content_state: content_state, workspace: self)
+ @revision ||= Revision.new(id: revision_id, workspace: self)
end
def base_revision
if base_revision_id
@base_revision ||= Revision.new(
id: base_revision_id,
- content_state: base_content_state,
workspace: self,
base: true
)
end
end
@@ -254,9 +254,25 @@
@obj_classes ||= ObjClassCollection.new(self)
end
def inspect
"<#{self.class} id=\"#{id}\" title=\"#{title}\">"
+ end
+
+ def has_modification_for?(obj_id)
+ !!objs.find_including_deleted(obj_id).modification
+ rescue Scrivito::ResourceNotFound
+ false
+ end
+
+ def self.all_with_modification_for(obj_id)
+ all.select do |ws|
+ ws.has_modification_for?(obj_id)
+ end
+ end
+
+ def conflict_warning_for(obj_id)
+ self.class.all_with_modification_for(obj_id) - [self]
end
private
def backend_url