Merged in OS-86-path-staff-get-new-tickets (pull request #67)

OS-86 path staff get new tickets
This commit is contained in:
Ivan Diaz 2016-10-18 17:38:00 +00:00
commit 96c01cc357
5 changed files with 49 additions and 0 deletions

View File

@ -3,6 +3,7 @@ require_once 'staff/get.php';
require_once 'staff/assign-ticket.php';
require_once 'staff/un-assign-ticket.php';
require_once 'staff/get-tickets.php';
require_once 'staff/get-new-tickets.php';
$systemControllerGroup = new ControllerGroup();
$systemControllerGroup->setGroupPath('/staff');
@ -11,5 +12,6 @@ $systemControllerGroup->addController(new GetStaffController);
$systemControllerGroup->addController(new AssignStaffController);
$systemControllerGroup->addController(new UnAssignStaffController);
$systemControllerGroup->addController(new GetTicketStaffController);
$systemControllerGroup->addController(new GetNewTicketsStaffController);
$systemControllerGroup->finalize();

View File

@ -0,0 +1,26 @@
<?php
use Respect\Validation\Validator as DataValidator;
class GetNewTicketsStaffController extends Controller {
const PATH = '/get-new-tickets';
public function validations() {
return[
'permission' => 'staff_1',
'requestData' => []
];
}
public function handler() {
$user = Controller::getLoggedUser();
$query = ' (';
foreach ($user->sharedDepartmentList as $department) {
$query .= 'department_id=' . $department->id . ' OR ';
}
$query = substr($query,0,-3);
$query .= ') AND owner_id IS NULL';
$ticketList = Ticket::find($query);
Response::respondSuccess($ticketList->toArray());
}
}

View File

@ -30,6 +30,11 @@ abstract class DataStore {
return $dataStoreList;
}
public static function find($query) {
$beanList = RedBean::find(static::TABLE,$query);
return DataStoreList::getList(ucfirst(static::TABLE),$beanList);
}
private static function validateProp($propToValidate) {
$validProp = false;

View File

@ -30,5 +30,6 @@ require './staff/assign-ticket.rb'
require './staff/un-assign-ticket.rb'
require './staff/get-tickets.rb'
require './ticket/change-priority.rb'
require './staff/get-new-tickets.rb'

View File

@ -0,0 +1,15 @@
describe '/staff/get-new-tickets' do
request('/user/logout')
Scripts.login($staff[:email], $staff[:password], true)
it 'should get news tickets' do
result = request('/staff/get-new-tickets', {
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
(result['status']).should.equal('success')
(result['data'].size).should.equal(7)
end
end