Commit a947b23e authored by o@immerda.ch's avatar o@immerda.ch
Browse files

support for force delete domain (with users)

parent 79534a11
function enableDelete() {
document.getElementById('enable_delete_form').style.display = 'none';
document.getElementById('delete_form').style.display = 'block';
}
function loadActions() {
if (document.getElementById('enable_delete_form'))
document.getElementById('enable_delete_form').addEventListener("click", enableDelete);
}
window.addEventListener("load", loadActions)
......@@ -121,8 +121,8 @@ module ApiBackend
post(['domains', 'create'], {'domain' => domain, 'values' => values})
end
def delete_domain(domain)
post(['domains', 'delete'], {'domain' => domain})
def delete_domain(domain, opts = {})
post(['domains', 'delete'], opts.merge('domain' => domain))
end
def storagehosts
get(['mail', 'storagehosts'], {})
......
......@@ -17,17 +17,20 @@ class DomainsController < AdminController
}
api.update_domain(@domain['domain'], values)
redirect_to '/domains' and return
rescue ApiBackend::ApiError
flash[:danger] = :fail
rescue ApiBackend::ApiError => e
flash[:danger] = e.api_msg
@domain = values.merge({'domain' => @domain['domain'] })
render 'edit'
end
def delete
api.delete_domain(@domain['domain'])
opts = {}
opts['force_delete'] = true if params[:forcedelete] == '1'
api.delete_domain(@domain['domain'], opts)
redirect_to domains_path and return
rescue ApiBackend::ApiError
flash[:danger] = :fail
rescue ApiBackend::ApiError => e
flash[:danger] = e.api_msg
render 'edit'
end
def create
......
......@@ -29,8 +29,14 @@
<br />
<br />
<br />
<div id="delete_form" style="display:none">
<%= form_tag("#{domains_path}/#{URI.escape(@domain['domain'])}/delete", method: "post") do %>
<%= hidden_field_tag(:delete, '', value: true) %>
<input type="checkbox" id="forcedelete" name="forcedelete" value="1" />
<%= t(:force_delete) %>
<br />
<%= submit_tag(t :delete) %>
DANGER DATA LOSS!!!
<% end %>
</div>
<a href="#" id="enable_delete_form"/><%= t(:delete) %></a>
Supports Markdown
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