Merge remote-tracking branch 'origin/master'

This commit is contained in:
2018-04-30 17:40:33 +02:00
12 changed files with 220 additions and 50 deletions

View File

@@ -33,26 +33,29 @@ class SingleTaskController extends Controller
public function newAction(Request $request)
{
$personId = $request->query->getInt('person_id', null);
$task = (new SingleTask())
->setAssignee($this->getUser())
->setType('task_default')
;
if ($personId === null) {
return new Response("You must provide a person_id", Response::HTTP_BAD_REQUEST);
if ($request->query->has('person_id')) {
$personId = $request->query->getInt('person_id', null);
if ($personId === null) {
return new Response("You must provide a person_id", Response::HTTP_BAD_REQUEST);
}
$person = $this->getDoctrine()->getManager()
->getRepository(Person::class)
->find($personId);
if ($person === null) {
$this->createNotFoundException("Invalid person id");
}
$task->setPerson($person);
}
$person = $this->getDoctrine()->getManager()
->getRepository(Person::class)
->find($personId);
if ($person === null) {
$this->createNotFoundException("Invalid person id");
}
$task = (new SingleTask())
->setAssignee($this->getUser())
->setPerson($person)
->setType('task_default')
;
$this->denyAccessUnlessGranted(TaskVoter::CREATE, $task, 'You are not '
. 'allowed to create this task');
@@ -69,7 +72,7 @@ class SingleTaskController extends Controller
$this->addFlash('success', "The task is created");
return $this->redirectToRoute('chill_task_task_list_by_person', [
return $this->redirectToRoute('chill_task_singletask_list', [
'person_id' => $task->getPerson()->getId()
]);