Merge branch 'master' of gitlab.com:jankstudio/resq

This commit is contained in:
Ramon Gutierrez 2018-02-05 13:20:24 +08:00
commit f3ad3fe807

View file

@ -422,6 +422,12 @@ class JobOrderController extends BaseController
{ {
$this->denyAccessUnlessGranted('jo_proc.list', null, 'No access.'); $this->denyAccessUnlessGranted('jo_proc.list', null, 'No access.');
// get object data
$em = $this->getDoctrine()->getManager();
$obj = $em->getRepository(JobOrder::class)->find($id);
$processor = $obj->getProcessedBy();
$user = $this->getUser();
// check if we're the one processing, return error otherwise // check if we're the one processing, return error otherwise
if ($processor == null) if ($processor == null)
throw $this->createAccessDeniedException('Not the processor'); throw $this->createAccessDeniedException('Not the processor');
@ -432,9 +438,6 @@ class JobOrderController extends BaseController
// initialize error list // initialize error list
$error_array = []; $error_array = [];
// get object data
$em = $this->getDoctrine()->getManager();
$obj = $em->getRepository(JobOrder::class)->find($id);
// make sure this object exists // make sure this object exists
if (empty($obj)) if (empty($obj))
@ -492,10 +495,6 @@ class JobOrderController extends BaseController
], 422); ], 422);
} }
// unlock job order and set version to 0, so someone else can modify it
// NOTE: we don't touch processed_by since we're the one who processed it
$obj->setVersion(0);
// validated! save the entity // validated! save the entity
$em->flush(); $em->flush();