@RequestMapping(value = "{postSlug}/delete", method = RequestMethod.POST) public RedirectView delete( @PathVariable ExecutionCourse executionCourse, @PathVariable String postSlug) { Post post = executionCourse.getSite().postForSlug(postSlug); atomic(() -> post.delete()); return viewAll(executionCourse); }
@RequestMapping(value = "{postSlug}/edit", method = RequestMethod.POST) public RedirectView edit( @PathVariable ExecutionCourse executionCourse, @PathVariable String postSlug, @RequestParam LocalizedString name, @RequestParam LocalizedString body) { Post post = executionCourse.getSite().postForSlug(postSlug); atomic( () -> { post.setName(Post.sanitize(name)); post.setBody(Post.sanitize(body)); }); return viewAll(executionCourse); }
@RequestMapping(value = "create", method = RequestMethod.POST) public RedirectView create( @PathVariable ExecutionCourse executionCourse, @RequestParam LocalizedString name, @RequestParam LocalizedString body) throws Exception { Site site = executionCourse.getSite(); atomic( () -> Post.create( site, null, Post.sanitize(name), Post.sanitize(body), announcementsCategory(site), true, getUser())); return viewAll(executionCourse); }