Commit 8dd4c738 authored by Ted Trask's avatar Ted Trask

Made changes for new handle_form style and remove redirect_to_referrer

parent b3a4a114
......@@ -31,10 +31,9 @@ function createdomain(self)
end
function editdomain(self)
return self.handle_form(self, function() return self.model.getDomain(self.clientdata.domain) end,
self.model.setDomain, self.clientdata, "Save", "Edit Domain Entry", "Domain Saved")
return self.handle_form(self, self.model.getDomain, self.model.setDomain, self.clientdata, "Save", "Edit Domain Entry", "Domain Saved")
end
function deletedomain(self)
return self:redirect_to_referrer(self.model.deleteDomain(self.clientdata.domain))
return self.handle_form(self, self.model.getDeleteDomain, self.model.deleteDomain, self.clientdata, "Delete", "Delete Domain Entry", "Domain Deleted")
end
......@@ -17,7 +17,7 @@ require("htmlviewfunctions")
<TD style="padding-right:20px;white-space:nowrap;">
<% io.write(html.link{value = "editdomain?domain=" .. domain.."&redir="..page_info.orig_action, label="Edit " }) %>
<% if domain ~= "@" then
io.write(html.link{value = "deletedomain?domain=" .. domain, label="Delete " })
io.write(html.link{value = "deletedomain?submit=true&domain=" .. domain, label="Delete " })
end %>
</TD>
<TD style="white-space:nowrap;" width="90%"><%= html.html_escape(domain) %></TD>
......
......@@ -192,7 +192,8 @@ function setNewDomain(self, domain)
return domain
end
function getDomain(getdomainname)
function getDomain(self, clientdata)
local getdomainname = clientdata.domain
local domain = cfe({ value=getdomainname, label="Domain", errtxt="Invalid domain" })
local iplist = cfe({ type="list", value={}, label="List of DNS servers" })
local domains = getDomains()
......@@ -222,20 +223,26 @@ function setDomain(self, domain)
return domain
end
function deleteDomain(domainname)
local cmdresult = cfe({ value="Domain not deleted", label="Delete domain result", errtxt="Invalid domain" })
function getDeleteDomain(self, clientdata)
local domain = cfe({ value=clientdata.domain or "", label="Domain" })
return cfe({ type="group", value={domain=domain}, label="Delete Domain" })
end
function deleteDomain(self, domain)
domain.errtxt = "Domain not deleted"
domain.value.domain.errtxt = "Invalid domain"
local domains = getDomains()
if domainname == "@" then
cmdresult.errtxt = "Cannot delete root domain"
if domain.value.domain.value == "@" then
domain.value.domain.errtxt = "Cannot delete root domain"
else
for i,name in ipairs(domains.value) do
if name == domainname then
if name == domain.value.domain.value then
os.remove(baseurl.."servers/"..name)
cmdresult.errtxt = nil
cmdresult.value = "Domain deleted"
domain.errtxt = nil
domain.value.domain.errtxt = nil
break
end
end
end
return cmdresult
return domain
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment