lib/scrivito/controller_actions.rb in scrivito_sdk-0.50.1 vs lib/scrivito/controller_actions.rb in scrivito_sdk-0.60.0.rc1
- old
+ new
@@ -82,11 +82,11 @@
def require_authenticated_editor
head(:forbidden) unless editing_context.authenticated_editor?
end
def editing_context
- request.env[EditingContextMiddleware::ENVKEY] || EditingContext.new
+ EditingContextMiddleware.from_request(request)
end
delegate :comparison, to: :editing_context
def load_object
@@ -95,12 +95,20 @@
raise loaded_obj if loaded_obj.is_a?(StandardError)
@obj = loaded_obj
end
def load_widget
- if widget = @obj.widget_from_pool(params[:widget_id])
- widget
- elsif comparison.active? # The "diff" mode.
+ widget = widget_from_current_revision || widget_from_base_revision
+ raise ResourceNotFound, "Widget with ID #{params[:widget_id]} not found!" unless widget
+ widget
+ end
+
+ def widget_from_current_revision
+ @obj.widget_from_pool(params[:widget_id])
+ end
+
+ def widget_from_base_revision
+ if comparison.active? # The "diff" mode.
@obj.in_revision(editing_context.selected_workspace.base_revision)
.widget_from_pool(params[:widget_id])
end
end