optimize detail pages, add new permission for comment posting (#1432)

This commit is contained in:
Kevin Papst
2020-02-02 18:16:23 +01:00
committed by GitHub
parent 6a533579b7
commit 69cf7015d8
12 changed files with 95 additions and 81 deletions

View File

@@ -168,7 +168,7 @@ final class CustomerController extends AbstractController
/**
* @Route(path="/{id}/comment_add", name="customer_comment_add", methods={"POST"})
* @Security("is_granted('edit', customer) and is_granted('comments', customer)")
* @Security("is_granted('comments_create', customer)")
*/
public function addCommentAction(Customer $customer, Request $request)
{
@@ -271,12 +271,8 @@ final class CustomerController extends AbstractController
$teams = null;
$projects = null;
if ($this->isGranted('edit', $customer)) {
$commentForm = $this->getCommentForm($customer, new CustomerComment())->createView();
if ($this->isGranted('create_team')) {
$defaultTeam = $teamRepository->findOneBy(['name' => $customer->getName()]);
}
if ($this->isGranted('edit', $customer) && $this->isGranted('create_team')) {
$defaultTeam = $teamRepository->findOneBy(['name' => $customer->getName()]);
}
if (null !== $customer->getTimezone()) {
@@ -291,6 +287,10 @@ final class CustomerController extends AbstractController
$comments = $this->repository->getComments($customer);
}
if ($this->isGranted('comments_create', $customer)) {
$commentForm = $this->getCommentForm($customer, new CustomerComment())->createView();
}
if ($this->isGranted('permissions', $customer) || $this->isGranted('details', $customer) || $this->isGranted('view_team')) {
$teams = $customer->getTeams();
}