front-end/design single tasks

This commit is contained in:
nobohan
2018-04-30 14:53:57 +02:00
parent 5d8b764057
commit f5b09cf42e
6 changed files with 151 additions and 42 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()
]);