Refactored delete action for HopObject, Site and Comment

This commit is contained in:
Tobi Schäfer 2014-12-10 16:50:16 +01:00
parent b6693b0e83
commit 5688cabffa
4 changed files with 33 additions and 21 deletions

View file

@ -22,14 +22,13 @@ $(function() {
});
});
</script>
<div>
<div class='uk-alert uk-alert-warning'>
<input type="checkbox" id="mode" name="mode" value="user" />
<label for="mode"><% gettext "Erase all comments of user {0}"
<% comment.creator %> %></label>
</div>
<div id="confirmation">
<input type="checkbox" id="confirm" name="confirm" value="1" />
<label for="confirm"><% ngettext "Yes, really erase {0} comment"
"Yes, really erase {0} comments" <% comment.related.size %> %></label>
</div>
<br />
</div>

View file

@ -1,14 +1,18 @@
<% #confirm %>
<h1><% gettext Warning! %></h1>
<p class='uk-text-bold'><% param.text %></p>
<p>
<% gettext 'Please be aware of the fact that there is no “undo”, so if you click “Proceed” below the changes will be applied irreversibly.' %>
</p>
<p>
<% gettext 'Click “Cancel” now if you are not really sure you want to proceed.' %>
</p>
<form action="<% response.action %>" method="post">
<p class="storyTitle"><% gettext Warning! %></p>
<p><% param.text %></p>
<p><% gettext 'Please be aware of the fact that there is no “undo”, so if you
click “Proceed” below the changes will be applied irreversibly.' %></p>
<p><% gettext 'Click “Cancel” now if you are not really sure you want to
proceed.' %></p>
<% this.skin <% this.type prefix=$ suffix=#delete %> %>
<p><button type="submit" name="proceed" value="1"><% gettext Proceed %></button>
<a href="" class="cancel"><strong><% gettext Cancel %></strong></a></p>
<p>
<button class='uk-button uk-button-danger' name="proceed" value="1"><% gettext Proceed %></button>
<a href="" class="uk-button uk-button-link cancel"><% gettext Cancel %></a>
</p>
</form>
<% #notify_create %>

View file

@ -169,8 +169,7 @@ HopObject.prototype.delete_action = function() {
if (req.postParams.proceed) {
try {
var parent = this._parent;
var url = this.constructor.remove.call(this, req.postParams) ||
parent.href();
var url = this.constructor.remove.call(this, req.postParams) || parent.href();
res.message = gettext('{0} was successfully deleted.', gettext(this._prototype));
res.redirect(User.getLocation() || url);
} catch(ex) {

View file

@ -293,7 +293,7 @@ referrers.push(new Antville.Referrer("<% param.referrer %>",
</div>
</div>
</fieldset>
<a name='admin' id='admin'></a>
<fieldset class='uk-margin-large-top'>
<legend><% gettext Admin %></legend>
<div class='uk-form-row'>
@ -320,7 +320,6 @@ referrers.push(new Antville.Referrer("<% param.referrer %>",
</a>
</div>
</fieldset>
<div class='uk-margin-large-top'>
<button class='uk-button uk-button-primary' type="submit" id="submit" name="save" value="1">
<% gettext Save %>
@ -337,6 +336,17 @@ $(function() {
});
</script>
<% #delete %>
<div class='uk-alert uk-alert-danger'>
<% gettext 'You are about to delete the whole site which currently contains {0}, {1}, {2}, {3} and {4}.'
<% ngettext '{0} story' '{0} stories' <% count <% site.self stories %> %> %>
<% ngettext '{0} comment' '{0} comments' <% count <% site.self comments %> %> %>
<% ngettext '{0} image' '{0} images' <% count <% site.self images %> %> %>
<% ngettext '{0} file' '{0} files' <% count <% site.self files %> %> %>
<% ngettext '{0} poll' '{0} polls' <% count <% site.self polls %> %> %> %>
<strong><% gettext 'All of this will be deleted irreversibly.' %></strong>
<% gettext 'Are you sure you want to proceed?' %>
</div>
<% #notify_block %>
<% gettext 'Hello {0}.' <% membership.name %> %>