<commit_before><?php

/*
 * This file is part of the Incipio package.
 *
 * (c) <NAME>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace mgate\SuiviBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use mgate\SuiviBundle\Entity\Etude;
use mgate\SuiviBundle\Entity\Mission;

class MissionController extends Controller
{
    /**
     * @Security("has_role('ROLE_SUIVEUR')")
     */
    public function indexAction($page)
    {
        $em = $this->getDoctrine()->getManager();

        $entities = $em->getRepository('mgateSuiviBundle:Etude')->findAll();

        return $this->render('mgateSuiviBundle:Etude:index.html.twig', array(
                    'etudes' => $entities,
                ));
    }

    /**
     * @Security("has_role('ROLE_SUIVEUR')")
     * @param Request $request
     * @return Response
     */
    public function avancementAction(Request $request)
    {
        $em = $this->getDoctrine()->getManager();
        // TODO : use a symfony form instead a simili php.
        $avancement = !empty($request->request->get('avancement')) ? intval($request->request->get('avancement')) : 0;
        $id = !empty($request->request->get('id')) ? $request->request->get('id') : 0;
        $intervenant = !empty($request->request->get('intervenant')) ? intval($request->request->get('intervenant')) : 0;

        $etude = $em->getRepository('mgate\SuiviBundle\Entity\Etude')->find($id);
        if (!$etude) {
            throw $this->createNotFoundException('L\'étude n\'existe pas !');
        } else {
            $etude->getMissions()->get($intervenant)->setAvancement($avancement);
            $em->persist($etude->getMissions()->get($intervenant));
            $em->flush();
        }

        return new Response('ok !');
    }

}<commit_msg>Add redirect after post on MissionController:avancement<commit_after><?php

/*
 * This file is part of the Incipio package.
 *
 * (c) <NAME>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace mgate\SuiviBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use mgate\SuiviBundle\Entity\Etude;
use mgate\SuiviBundle\Entity\Mission;

class MissionController extends Controller
{
    /**
     * @Security("has_role('ROLE_SUIVEUR')")
     */
    public function indexAction($page)
    {
        $em = $this->getDoctrine()->getManager();

        $entities = $em->getRepository('mgateSuiviBundle:Etude')->findAll();

        return $this->render('mgateSuiviBundle:Etude:index.html.twig', array(
                    'etudes' => $entities,
                ));
    }

    /**
     * @Security("has_role('ROLE_SUIVEUR')")
     * @param Request $request
     * @return Response
     */
    public function avancementAction(Request $request)
    {

        if ($this->get('request')->getMethod() == 'POST') {

            $em = $this->getDoctrine()->getManager();
            // TODO : use a symfony form instead a simili php.
            $avancement = !empty($request->request->get('avancement')) ? intval($request->request->get('avancement')) : 0;
            $id = !empty($request->request->get('id')) ? $request->request->get('id') : 0;
            $intervenant = !empty($request->request->get('intervenant')) ? intval($request->request->get('intervenant')) : 0;

            $etude = $em->getRepository('mgate\SuiviBundle\Entity\Etude')->find($id);
            if (!$etude) {
                throw $this->createNotFoundException('L\'étude n\'existe pas !');
            } else {
                $etude->getMissions()->get($intervenant)->setAvancement($avancement);
                $em->persist($etude->getMissions()->get($intervenant));
                $em->flush();
            }
            return $this->redirect($this->generateUrl('mgateSuivi_mission_avancement'));
        }

        return new Response('ok !');
    }

}
{'fraction_non_alphanumeric': 0.1585506577429033, 'fraction_numerical': 0.0013847219016847449, 'mean_word_length': 3.020408163265306, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 69, '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': '1885245', 'n_tokens_mistral': 1300, 'n_tokens_neox': 1260, 'n_words': 228}