Skip to content

Commit

Permalink
Merged release/v0.1 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Young committed Sep 11, 2016
2 parents 02ccacf + 13e3bcd commit 21d87c6
Show file tree
Hide file tree
Showing 11 changed files with 276 additions and 196 deletions.
2 changes: 2 additions & 0 deletions app/config/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ security:
# realm: "Secured Demo Area"
remember_me:
key: %secret%
acl:
connection: default

# with these settings you can restrict or allow access for different parts
# of your application based on roles, ip, host or methods
Expand Down
5 changes: 3 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
"angular-resource": "~1.4.6",
"angular-route": "~1.4.6",
"angular-routing": "~0.1.2",
"angular-xeditable": "~0.1.9",
"angular-xeditable": "~0.3",
"bootstrap": "~3.3.5",
"font-awesome": "~4.4.0",
"jquery": "~2.1.4",
"jquery-ui": "~1.11.4",
"lodash": "~3.10.1",
"angular-bootstrap": "~0.14.0",
"moment": "~2.10.6",
"bPopup": "bpopup#~0.11.0"
"bPopup": "bpopup#~0.11.0",
"angular-smart-table": "^2.1.8"
},
"resolutions": {
"angular": "1.4.8",
Expand Down
25 changes: 15 additions & 10 deletions src/Darkbluesun/GoldfishBundle/Controller/ClientController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
namespace Darkbluesun\GoldfishBundle\Controller;

use JMS\Serializer\SerializationContext;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Darkbluesun\GoldfishBundle\Entity\Workspace;
use Darkbluesun\GoldfishBundle\Entity\Client;
use Darkbluesun\GoldfishBundle\Entity\ClientComment;
use Symfony\Component\Security\Acl\Domain\ObjectIdentity;
use Symfony\Component\Security\Acl\Domain\UserSecurityIdentity;
use Symfony\Component\Security\Acl\Permission\MaskBuilder;

/**
* Client controller.
Expand All @@ -26,9 +28,8 @@ class ClientController extends Controller
*
* @Route("/", name="clients")
* @Method("GET")
* @Template()
*/
public function indexAction()
public function getcAction()
{
$user = $this->get('security.context')->getToken()->getUser();
$workspace = $user->getWorkspace();
Expand All @@ -52,7 +53,7 @@ public function indexAction()

/**
* Gets an existing Client entity.
*
* @Security("is_granted('VIEW', client)")
* @Route("/{id}", name="clients_get")
* @Method("GET")
*/
Expand All @@ -65,7 +66,6 @@ public function getAction(Client $client)
*
* @Route("", name="clients_create")
* @Method("POST")
* @Template("DarkbluesunGoldfishBundle:Client:new.html.twig")
*/
public function createAction(Request $request)
{
Expand All @@ -76,15 +76,20 @@ public function createAction(Request $request)
$client->setCreatedAt(new \DateTime())->setUpdatedAt(new \DateTime());
$em->persist($client);
$em->flush();

$aclProvider = $this->get('security.acl.provider');
$acl = $aclProvider->createAcl(ObjectIdentity::fromDomainObject($client));
$acl->insertObjectAce(UserSecurityIdentity::fromAccount($this->getUser()), MaskBuilder::MASK_OWNER);
$aclProvider->updateAcl($acl);

return $this->getAction($client);
}

/**
* Edits an existing Client entity.
*
* Updates an existing Client entity.
* @Security("is_granted('EDIT', client)")
* @Route("/{id}", name="clients_update")
* @Method("POST")
* @Template("DarkbluesunGoldfishBundle:Client:edit.html.twig")
*/
public function updateAction(Request $request, Client $client)
{
Expand Down Expand Up @@ -118,7 +123,7 @@ public function commentAction(Request $request, Client $client) {

/**
* Deletes a Client entity.
*
* @Security("is_granted('DELETE', client)")
* @Route("/{id}", name="clients_delete")
* @Method("DELETE")
*/
Expand Down
26 changes: 17 additions & 9 deletions src/Darkbluesun/GoldfishBundle/Controller/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
namespace Darkbluesun\GoldfishBundle\Controller;

use JMS\Serializer\SerializationContext;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Darkbluesun\GoldfishBundle\Entity\Client;
use Darkbluesun\GoldfishBundle\Entity\Project;
use Darkbluesun\GoldfishBundle\Entity\Task;
use Darkbluesun\GoldfishBundle\Form\ProjectType;
use Symfony\Component\Security\Acl\Domain\ObjectIdentity;
use Symfony\Component\Security\Acl\Domain\UserSecurityIdentity;
use Symfony\Component\Security\Acl\Permission\MaskBuilder;

/**
* Project controller.
Expand All @@ -29,7 +31,7 @@ class ProjectController extends Controller
* @Route("/", name="project")
* @Method("GET")
*/
public function indexAction()
public function getcAction()
{
return new Response(
$this->get('serializer')->serialize(
Expand All @@ -40,7 +42,7 @@ public function indexAction()

/**
* Get a Project
*
* @Security("is_granted('VIEW', project)")
* @Route("/{id}", name="project_get")
* @Method("GET")
*/
Expand All @@ -55,20 +57,26 @@ public function getAction(Project $project)
* @Route("", name="project_create")
* @Method("POST")
*/
public function createAction(Request $request)
public function postAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$project = $this->get('serializer')->deserialize($request->getContent(), Project::class, 'json');
$project->setWorkspace($this->getUser()->getWorkspace());
$project = $em->merge($project);
$project->setCreatedAt(new \DateTime())->setUpdatedAt(new \DateTime());
$em->flush();

$aclProvider = $this->get('security.acl.provider');
$acl = $aclProvider->createAcl(ObjectIdentity::fromDomainObject($project));
$acl->insertObjectAce(UserSecurityIdentity::fromAccount($this->getUser()), MaskBuilder::MASK_OWNER);
$aclProvider->updateAcl($acl);

return $this->getAction($project);
}

/**
* Edits an existing Project entity.
*
* Updates an existing Project entity.
* @Security("is_granted('EDIT', project)")
* @Route("/{id}", name="project_update")
* @Method("POST")
*/
Expand All @@ -85,11 +93,11 @@ public function updateAction(Request $request, Project $project)

/**
* Deletes a Project.
*
* @Security("is_granted('DELETE', project)")
* @Route("/{id}", name="project_delete")
* @Method("DELETE")
*/
public function destroyAction(Request $request, Project $project)
public function deleteAction(Request $request, Project $project)
{
$this->requireWorkspace($project);
$em->remove($project);
Expand Down
39 changes: 22 additions & 17 deletions src/Darkbluesun/GoldfishBundle/Controller/TaskController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
namespace Darkbluesun\GoldfishBundle\Controller;

use JMS\Serializer\SerializationContext;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Darkbluesun\GoldfishBundle\Entity\Client;
use Darkbluesun\GoldfishBundle\Entity\Project;
use Darkbluesun\GoldfishBundle\Entity\Task;
use Darkbluesun\GoldfishBundle\Entity\User;
use Darkbluesun\GoldfishBundle\Entity\TimeEntry;
use Darkbluesun\GoldfishBundle\Form\TaskType;
use Symfony\Component\Security\Acl\Domain\ObjectIdentity;
use Symfony\Component\Security\Acl\Domain\UserSecurityIdentity;
use Symfony\Component\Security\Acl\Permission\MaskBuilder;

/**
* Task controller.
Expand All @@ -30,7 +30,7 @@ class TaskController extends Controller
* @Route("/", name="tasks_list")
* @Method("GET")
*/
public function listAction()
public function getcAction()
{
return new Response(
$this->get('serializer')->serialize(
Expand All @@ -41,7 +41,7 @@ public function listAction()

/**
* Gets a Task.
*
* @Security("is_granted('view', task)")
* @Route("/{id}", name="tasks_get")
* @Method("GET")
*/
Expand All @@ -60,7 +60,7 @@ public function getAction(Task $task)
* @Route("", name="tasks_create")
* @Method("POST")
*/
public function createAction(Request $request)
public function postAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$task = $this->get('serializer')->deserialize($request->getContent(), Task::class, 'json');
Expand All @@ -69,12 +69,17 @@ public function createAction(Request $request)
$task = $em->merge($task);
$em->flush();

$aclProvider = $this->get('security.acl.provider');
$acl = $aclProvider->createAcl(ObjectIdentity::fromDomainObject($task));
$acl->insertObjectAce(UserSecurityIdentity::fromAccount($this->getUser()), MaskBuilder::MASK_OWNER);
$aclProvider->updateAcl($acl);

return $this->getAction($task);
}

/**
* Edits an existing Task.
*
* Updates an existing Task.
* @Security("is_granted('EDIT', task)")
* @Route("/{id}", name="tasks_update")
* @Method("POST")
*/
Expand All @@ -92,11 +97,11 @@ public function updateAction(Request $request, Task $task)

/**
* Deletes a Task.
*
* @Security("is_granted('DELETE', task)")
* @Route("/{id}", name="tasks_delete")
* @Method("DELETE")
*/
public function destroyAction(Request $request, Task $task)
public function deleteAction(Request $request, Task $task)
{
$em = $this->getDoctrine()->getManager();
$em->remove($task);
Expand All @@ -106,11 +111,11 @@ public function destroyAction(Request $request, Task $task)

/**
* Lists all Comments belonging to this thing.
*
* @Security("is_granted('VIEW', task)")
* @Route("/{id}/comments", name="task_comment_list")
* @Method("GET")
*/
public function commentsAction(Task $task)
public function getCommentsAction(Task $task)
{
return new Response(
$this->get('serializer')->serialize(
Expand All @@ -121,11 +126,11 @@ public function commentsAction(Task $task)

/**
* List all time entries
*
* @Security("is_granted('VIEW', task)")
* @Route("/{id}/timesheet/", name="task_timesheet")
* @Method("GET")
*/
public function timesheetAction(Task $task) {
public function getTimesheetAction(Task $task) {
return new Response(
$this->get('serializer')->serialize(
$task->getTimeEntries(), 'json',
Expand All @@ -135,11 +140,11 @@ public function timesheetAction(Task $task) {

/**
* Time add
*
* @Security("is_granted('EDIT', task)")
* @Route("/{id}/addtime", name="task_add_time")
* @Method("POST")
*/
public function addTimeAction(Request $request, Task $task) {
public function postTimeAction(Request $request, Task $task) {
$em = $this->getDoctrine()->getManager();
$entry = $this->get('serializer')->deserialize($request->getContent(), TimeEntry::class, 'json');
$entry->setTask($task);
Expand Down
1 change: 1 addition & 0 deletions src/Darkbluesun/GoldfishBundle/Resources/public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var goldfishApp = angular.module('goldfishApp', [
'goldfishControllers',
'ngResource',
'xeditable',
'smart-table',
'ui.bootstrap'
]);

Expand Down
Loading

0 comments on commit 21d87c6

Please sign in to comment.