Class: Fiona7::Controllers::RestAPI::WorkspaceController
- Inherits:
-
Object
- Object
- Fiona7::Controllers::RestAPI::WorkspaceController
- Defined in:
- lib/fiona7/controllers/rest_api/workspace_controller.rb
Instance Method Summary collapse
- #all ⇒ Object
- #by_modified_obj ⇒ Object
- #changes(id) ⇒ Object
- #create(values) ⇒ Object
- #delete(id) ⇒ Object
- #fetch(id) ⇒ Object
- #publish(id) ⇒ Object
- #update(id) ⇒ Object
Instance Method Details
#all ⇒ Object
79 80 81 82 83 |
# File 'lib/fiona7/controllers/rest_api/workspace_controller.rb', line 79 def all results = [Workspace.published, Workspace.rtc] w = {'results' => results} ::JSON.parse(::ActiveSupport::JSON.encode(w)) end |
#by_modified_obj ⇒ Object
53 54 55 |
# File 'lib/fiona7/controllers/rest_api/workspace_controller.rb', line 53 def by_modified_obj ['rtc'] end |
#changes(id) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/fiona7/controllers/rest_api/workspace_controller.rb', line 19 def changes(id) id = id.to_sym Assert.exists( id == :published || id == :rtc, "Could not find Scrivito::Workspace with id #{id}" ) w = Workspace.new(id) w_json = ::JSON.parse(::ActiveSupport::JSON.encode(w)) { "workspace" => w_json, "current" => w.content_state_id, "objs" => "*" } end |
#create(values) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/fiona7/controllers/rest_api/workspace_controller.rb', line 62 def create(values) values ||= {} values[:workspace] ||= {} id = (values[:workspace][:id] || values[:workspace]["id"]) id = (id || :no_id_provided).to_sym Assert.constraint( id == :rtc, "Only rtc workspace can be created" ) w = Workspace.rtc # NOTE: this "creates" a rtc workspace # and breaks publish checker spec ... #WriteObj.root.take ; WriteObj.root.edit ::JSON.parse(::ActiveSupport::JSON.encode(w)) end |
#delete(id) ⇒ Object
49 50 51 |
# File 'lib/fiona7/controllers/rest_api/workspace_controller.rb', line 49 def delete(id) Assert.contraint(false, "Workspaces cannot be deleted") end |
#fetch(id) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/fiona7/controllers/rest_api/workspace_controller.rb', line 8 def fetch(id) id = id.to_sym Assert.exists( id == :published || id == :rtc, "Could not find Scrivito::Workspace with id #{id}" ) w = Workspace.new(id) return ::JSON.parse(::ActiveSupport::JSON.encode(w)) end |
#publish(id) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fiona7/controllers/rest_api/workspace_controller.rb', line 35 def publish(id) raise "Unexpected workspace_id: #{id}" unless id.to_s == "rtc" WriteObj.where(is_edited: 1).order('path DESC').each do |obj| begin obj.take obj.release! ::Fiona7.run_callbacks(:release_obj, obj.id) unless obj.path =~ /\/_widgets\// rescue => e raise "Release impossible of: #{obj.path} because: #{e.message}" end end {'task' => {'id' => '1', 'status' => 'success', 'result' => '1'}} end |
#update(id) ⇒ Object
57 58 59 60 |
# File 'lib/fiona7/controllers/rest_api/workspace_controller.rb', line 57 def update(id) # DUMMY NO OP {} end |