<commit_before>package musement



import grails.plugin.springsecurity.SpringSecurityService
import grails.plugin.springsecurity.annotation.Secured
import grails.transaction.Transactional
import musement.user.User;

@Transactional(readOnly = true)
class PostController {

    SpringSecurityService springSecurityService
    PostService postService

    /**
     * @param categoryId Id of the current category
     */
    @Secured(['IS_AUTHENTICATED_FULLY'])
    def getPosts() {
        /* Params: currentCategory */
        User u = springSecurityService.currentUser;
        Category c = Category.findById(params.get("categoryId"));
        /* Return concerned posts */
        def posts = Post.findAllByCategory(c, params).reverse();
        render(view:"/post/post_show", model: [posts: posts, categoryId: c.id, currentUser: u])
    }



    /**
     * @param categoryId Id of the current category
     */
    @Secured(['IS_AUTHENTICATED_FULLY'])
    def sendPost() {
        /* Params: currentCategory */
        User u = springSecurityService.currentUser;
        Category c = Category.findById(params.categoryId);
        String content = params.content;
        /* Send post using service */
        Post p = postService.sendPost(u, content, c);
        redirect ( controller: "userManagement", action: "home", params:[categoryId: params.categoryId])
    }


}<commit_msg>#82 - Manage Post<commit_after>package musement



import grails.plugin.springsecurity.SpringSecurityService
import grails.plugin.springsecurity.annotation.Secured
import grails.transaction.Transactional
import musement.user.User;

@Transactional(readOnly = true)
class PostController {

    SpringSecurityService springSecurityService
    PostService postService

    /**
     * @param categoryId Id of the current category
     */
    @Secured(['IS_AUTHENTICATED_FULLY'])
    def getPosts() {
        /* Params: currentCategory */
        User u = springSecurityService.currentUser;
        Category c = Category.findById(params.get("categoryId"));
        /* Return concerned posts */
        def posts = Post.findAllByCategory(c, params).reverse();
        render(view:"/post/post_show", model: [posts: posts, categoryId: c.id, currentUser: u])
    }



    /**
     * @param categoryId Id of the current category
     */
    @Secured(['IS_AUTHENTICATED_FULLY'])
    def sendPost() {
        /* Params: currentCategory */
        User u = springSecurityService.currentUser;
        Category c = Category.findById(params.categoryId);
        String content = params.content;
        /* Send post using service */
        Post p = postService.sendPost(u, content, c);
        redirect ( controller: "userManagement", action: "home", params:[categoryId: params.categoryId])
    }




}
{'fraction_non_alphanumeric': 0.10773680404916848, 'fraction_numerical': 0.0007230657989877079, 'mean_word_length': 3.1734539969834086, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3631899', 'n_tokens_mistral': 765, 'n_tokens_neox': 740, 'n_words': 178}