Updated CMS

This commit is contained in:
jvelilla
2014-10-01 17:47:16 -03:00
parent 5a5eb0dea2
commit 5525134148
15 changed files with 122 additions and 133 deletions

View File

@@ -69,9 +69,7 @@ feature -- HTTP Methods
-- Existing node
if attached {WSF_STRING} req.path_parameter ("id") as l_id then
if l_id.is_integer and then attached {CMS_NODE} api_service.node (l_id.integer_value) as l_node then
create {NODE_VIEW_CMS_RESPONSE} l_page.make (req, res, setup, "modules/node_summary")
l_page.add_variable (setup.is_html, "html")
l_page.add_variable (setup.is_web, "web")
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup, "modules/node_summary")
l_page.add_variable (l_node.summary, "summary")
l_page.add_variable (l_id.value, "id")
l_page.execute
@@ -79,11 +77,7 @@ feature -- HTTP Methods
do_error (req, res, l_id)
end
else
to_implement ("Check how to implement API error")
-- create l_page.make (req, "master2/error.tpl")
-- l_page.set_value ("500", "code")
-- l_page.set_value (req.absolute_script_url (req.path_info), "request")
-- l_page.send_to (res)
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup, "master2/error")).execute
end
else
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
@@ -103,22 +97,14 @@ feature -- HTTP Methods
if l_method.is_case_insensitive_equal ("PUT") then
do_put (req, res)
else
to_implement ("Check how to implement API error")
-- create l_page.make (req, "master2/error.tpl")
-- l_page.set_value ("500", "code")
-- l_page.set_value (req.absolute_script_url (req.path_info), "request")
-- l_page.send_to (res)
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup, "master2/error")).execute
end
end
else
do_error (req, res, l_id)
end
else
to_implement ("Check how to implement API error")
-- create l_page.make (req, "master2/error.tpl")
-- l_page.set_value ("500", "code")
-- l_page.set_value (req.absolute_script_url (req.path_info), "request")
-- l_page.send_to (res)
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup, "master2/error")).execute
end
else
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
@@ -130,7 +116,6 @@ feature -- HTTP Methods
local
u_node: CMS_NODE
do
to_implement ("Check if user has permissions!!!")
if attached current_user (req) as l_user then
if attached {WSF_STRING} req.path_parameter ("id") as l_id then
if l_id.is_integer and then attached {CMS_NODE} api_service.node (l_id.integer_value) as l_node then
@@ -142,11 +127,7 @@ feature -- HTTP Methods
do_error (req, res, l_id)
end
else
to_implement ("Check how to implement API error")
-- create l_page.make (req, "master2/error.tpl")
-- l_page.set_value ("500", "code")
-- l_page.set_value (req.absolute_script_url (req.path_info), "request")
-- l_page.send_to (res)
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup, "master2/error")).execute
end
else
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
@@ -155,21 +136,24 @@ feature -- HTTP Methods
feature -- Error
do_error (req: WSF_REQUEST; res: WSF_RESPONSE; a_id: WSF_STRING)
-- Handling error.
local
-- l_page: ROC_RESPONSE
l_page: CMS_RESPONSE
do
-- create l_page.make (req, "master2/error.tpl")
-- if a_id.is_integer then
-- -- resource not found
-- l_page.set_value ("404", "code")
-- else
-- -- bad request
-- l_page.set_value ("400", "code")
-- end
-- l_page.set_value (req.absolute_script_url (req.path_info), "request")
-- l_page.send_to(res)
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup, "master2/error")
l_page.add_variable (req.absolute_script_url (req.path_info), "request")
if a_id.is_integer then
-- resource not found
l_page.add_variable ("404", "code")
l_page.set_status_code (404)
else
-- bad request
l_page.add_variable ("400", "code")
l_page.set_status_code (400)
end
l_page.execute
end