From 22615a2ceb9c20af9248c7c50a874b573bc2c6f4 Mon Sep 17 00:00:00 2001 From: Luis Reyes Date: Fri, 20 Sep 2019 01:21:29 -0400 Subject: [PATCH 1/3] document creation redirects to document list --- actions/create_document.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/actions/create_document.lua b/actions/create_document.lua index fd576da..90a8ebe 100644 --- a/actions/create_document.lua +++ b/actions/create_document.lua @@ -28,10 +28,13 @@ end contentdb.write_file (store, id or document_uuid, fields, request.body.body) +-- html redirect example +local redirect = "" +log.debug(json.from_table(fields)) return { headers = { - ["content-type"] = "application/json", + ["content-type"] = "text/html", ["X-Request-ID"] = request.uuid }, - body = json.from_table(params) + body = redirect } From 754e68c0eab4a4d01ea7e0375f75e7a45043291d Mon Sep 17 00:00:00 2001 From: Luis Reyes Date: Fri, 20 Sep 2019 15:52:00 -0400 Subject: [PATCH 2/3] document json api changes --- actions/list_documents.lua | 28 +++++++++++++++++++--------- actions/list_subdocuments.lua | 3 +-- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/actions/list_documents.lua b/actions/list_documents.lua index c9636f4..48c2883 100644 --- a/actions/list_documents.lua +++ b/actions/list_documents.lua @@ -3,22 +3,32 @@ priority = 1 input_parameters = ["request"] -- GET /[type]/[uuid] + local model_name = request.path_segments[1] local uuids = {} -contentdb.walk_documents(nil, function (file_uuid, header, body) - if fields.model ~= model_name then return end - -- Filter the documents using the query params - for k, v in pairs(request.query) do - if header[k] ~= v then - -- Don't add this document to the list - return + +contentdb.walk_documents(nil, + function (file_uuid, fields, body, store) + if fields.model ~= model_name then return end + + -- Filter the documents using the query params + for k, v in pairs(request.query) do + if fields[k] ~= v then + -- Don't add this document to the list + return + end end + + table.insert(uuids, { + name = fields.name or fields.title, + uuid = file_uuid, + store = store + }) end +) - table.insert(uuids, file_uuid) -end) return { headers = { diff --git a/actions/list_subdocuments.lua b/actions/list_subdocuments.lua index 031bf7d..7b5347e 100644 --- a/actions/list_subdocuments.lua +++ b/actions/list_subdocuments.lua @@ -18,12 +18,11 @@ contentdb.walk_documents(nil, function (doc_id, fields, body) end) - if #uuids == 0 then uuids = nil end return { headers = { - ["content-type"] = "text/html", + ["content-type"] = "application/json", }, body = json.from_table({ base_model = base_model, From 0d90809e17e07c8302816ee252c23ea957d76ce2 Mon Sep 17 00:00:00 2001 From: Luis Reyes Date: Wed, 13 Nov 2019 23:45:12 -0400 Subject: [PATCH 3/3] removed unused code --- actions/create_document.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/actions/create_document.lua b/actions/create_document.lua index 90a8ebe..e16202a 100644 --- a/actions/create_document.lua +++ b/actions/create_document.lua @@ -28,9 +28,8 @@ end contentdb.write_file (store, id or document_uuid, fields, request.body.body) --- html redirect example local redirect = "" -log.debug(json.from_table(fields)) + return { headers = { ["content-type"] = "text/html",