Fixed: delete-trash a node.

Added code to remove path_aliase when we delete a node.
This commit is contained in:
jvelilla
2015-12-01 19:20:16 -03:00
parent 10102e80fa
commit 9da8b8a025
3 changed files with 32 additions and 21 deletions

View File

@@ -378,7 +378,21 @@ feature -- Form
to_implement ("Refactor code to use the new wsf_html HTML5 support")
f.extend_html_text("<input type='submit' value='Cancel' formmethod='GET', formaction='/node/"+a_node.id.out+"'>" )
end
f.extend_html_text ("<br/>")
f.extend_html_text ("<legend>Do you want to restore the current node?</legend>")
if
a_node /= Void and then
a_node.id > 0
then
create ts.make ("op")
ts.set_default_value ("Restore")
ts.set_formaction ("/node/"+a_node.id.out+"/delete")
ts.set_formmethod ("POST")
fixme ("[
ts.set_default_value (translation ("Restore"))
]")
f.extend (ts)
end
Result := f
end
@@ -404,19 +418,6 @@ feature -- Form
]")
f.extend (ts)
end
f.extend_html_text ("<br/>")
f.extend_html_text ("<legend>Do you want to restore the current node?</legend>")
if
a_node /= Void and then
a_node.id > 0
then
create ts.make ("op")
ts.set_default_value ("Restore")
fixme ("[
ts.set_default_value (translation ("Restore"))
]")
f.extend (ts)
end
Result := f
end

View File

@@ -173,6 +173,11 @@ feature -- HTTP Methods
l_op.value.same_string ("Delete")
then
do_delete (req, res)
elseif
attached {WSF_STRING} req.form_parameter ("op") as l_op and then
l_op.value.same_string ("Restore")
then
do_restore (req, res)
end
elseif req.percent_encoded_path_info.ends_with ("/trash") then
if
@@ -180,11 +185,6 @@ feature -- HTTP Methods
l_op.value.same_string ("Trash")
then
do_trash (req, res)
elseif
attached {WSF_STRING} req.form_parameter ("op") as l_op and then
l_op.value.same_string ("Restore")
then
do_restore (req, res)
end
elseif req.percent_encoded_path_info.starts_with ("/node/add/") then
create edit_response.make (req, res, api, node_api)

View File

@@ -383,6 +383,7 @@ feature -- Change: Node
local
l_parameters: STRING_TABLE [ANY]
l_time: DATE_TIME
l_sql_delete_node_aliases: STRING
do
create l_time.make_now_utc
write_information_log (generator + ".delete_node_base {" + a_node.id.out + "}")
@@ -396,6 +397,13 @@ feature -- Change: Node
-- we remove node_revisions and pages.
-- Check: maybe we need a transaction.
sql_modify (sql_delete_node_revisions, l_parameters)
sql_finalize
-- we remove node_aliases
-- Check: maybe we need a transaction.
create l_sql_delete_node_aliases.make_from_string (sql_delete_node_aliases)
l_sql_delete_node_aliases.replace_substring_all ("$nodeid", "node/" + a_node.id.out)
sql_modify (l_sql_delete_node_aliases, void)
sql_finalize
if not error_handler.has_error then
@@ -415,7 +423,7 @@ feature -- Change: Node
error_handler.reset
create l_parameters.make (1)
l_parameters.put (l_time, "changed")
l_parameters.put ({CMS_NODE_API}.not_published, "status")
l_parameters.put ({CMS_NODE_API}.published, "status")
l_parameters.put (a_id, "nid")
sql_modify (sql_restore_node, l_parameters)
sql_finalize
@@ -561,7 +569,7 @@ feature {NONE} -- Queries
-- Physical deletion with free metadata.
sql_restore_node: STRING = "UPDATE nodes SET changed=:changed, status =:status WHERE nid=:nid"
-- Restore node to {CMS_NODE_API}.not_publised.
-- Restore node to {CMS_NODE_API}.published
sql_last_insert_node_id: STRING = "SELECT MAX(nid) FROM nodes;"
@@ -584,6 +592,8 @@ feature {NONE} -- Queries
sql_delete_node_revisions: STRING = "DELETE FROM node_revisions WHERE nid=:nid;"
sql_delete_node_aliases: STRING = "DELETE FROM path_aliases WHERE source='$nodeid';"
feature {NONE} -- Sql Queries: USER_ROLES collaborators, author
Select_user_author: STRING = "SELECT uid, name, password, salt, email, users.status, users.created, signed FROM nodes INNER JOIN users ON nodes.author=users.uid AND nodes.nid = :nid AND nodes.revision = :revision;"