X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FDeletePostPage.java;h=ecbb36816f6d52ef82e88615ac8c06924c1c8722;hb=9e4db46b86d084eba9029906e779ec1d96f78ac4;hp=18262a21eb160f90c8712cabbbcd8c48dd4f70e0;hpb=a2715f410c410e95397ebbfabbe51a5abfd50387;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/DeletePostPage.java b/src/main/java/net/pterodactylus/sone/web/DeletePostPage.java index 18262a2..ecbb368 100644 --- a/src/main/java/net/pterodactylus/sone/web/DeletePostPage.java +++ b/src/main/java/net/pterodactylus/sone/web/DeletePostPage.java @@ -21,6 +21,7 @@ import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.web.page.Page.Request.Method; import net.pterodactylus.util.template.Template; +import net.pterodactylus.util.template.TemplateContext; /** * Lets the user delete a post they made. @@ -38,7 +39,7 @@ public class DeletePostPage extends SoneTemplatePage { * The Sone web interface */ public DeletePostPage(Template template, WebInterface webInterface) { - super("deletePost.html", template, "Page.DeletePost.Title", webInterface); + super("deletePost.html", template, "Page.DeletePost.Title", webInterface, true); } // @@ -49,19 +50,19 @@ public class DeletePostPage extends SoneTemplatePage { * {@inheritDoc} */ @Override - protected void processTemplate(Request request, Template template) throws RedirectException { - super.processTemplate(request, template); + protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException { + super.processTemplate(request, templateContext); if (request.getMethod() == Method.GET) { String postId = request.getHttpRequest().getParam("post"); String returnPage = request.getHttpRequest().getParam("returnPage"); - Post post = webInterface.core().getPost(postId); - template.set("post", post); - template.set("returnPage", returnPage); + Post post = webInterface.getCore().getPost(postId); + templateContext.set("post", post); + templateContext.set("returnPage", returnPage); return; } else if (request.getMethod() == Method.POST) { String postId = request.getHttpRequest().getPartAsStringFailsafe("post", 36); - String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 64); - Post post = webInterface.core().getPost(postId); + String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256); + Post post = webInterface.getCore().getPost(postId); Sone currentSone = getCurrentSone(request.getToadletContext()); if (!post.getSone().equals(currentSone)) { throw new RedirectException("noPermission.html"); @@ -72,21 +73,9 @@ public class DeletePostPage extends SoneTemplatePage { } else if (request.getHttpRequest().isPartSet("abortDelete")) { throw new RedirectException(returnPage); } - template.set("post", post); - template.set("returnPage", returnPage); + templateContext.set("post", post); + templateContext.set("returnPage", returnPage); } } - // - // SONETEMPLATEPAGE METHODS - // - - /** - * {@inheritDoc} - */ - @Override - protected boolean requiresLogin() { - return true; - } - }