From 82f73eb9e286ad88e6e1cbe316538476eea7c09d Mon Sep 17 00:00:00 2001 From: Steven Date: Fri, 23 Apr 2021 21:09:00 +0200 Subject: [PATCH 1/2] Added user locale to REST API GET /api/users response; (#9486) * Clearer reporting on import Signed-off-by: snipe * Try adding text/x-Algol68 to import Signed-off-by: snipe * Added user locale to REST API GET /api/users response; Co-authored-by: snipe --- app/Http/Controllers/Api/ImportController.php | 4 +++- app/Http/Controllers/Api/UsersController.php | 1 + app/Http/Transformers/UsersTransformer.php | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/ImportController.php b/app/Http/Controllers/Api/ImportController.php index 2f88e3f474..682f18d72b 100644 --- a/app/Http/Controllers/Api/ImportController.php +++ b/app/Http/Controllers/Api/ImportController.php @@ -49,10 +49,12 @@ class ImportController extends Controller if (!in_array($file->getMimeType(), array( 'application/vnd.ms-excel', 'text/csv', + 'application/csv', + 'text/x-Algol68', // because wtf CSV files? 'text/plain', 'text/comma-separated-values', 'text/tsv'))) { - $results['error']='File type must be CSV'; + $results['error']='File type must be CSV. Uploaded file is '.$file->getMimeType(); return response()->json(Helper::formatStandardApiResponse('error', null, $results['error']), 500); } diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php index 8efb0cd834..b8bbf39d4d 100644 --- a/app/Http/Controllers/Api/UsersController.php +++ b/app/Http/Controllers/Api/UsersController.php @@ -49,6 +49,7 @@ class UsersController extends Controller 'users.jobtitle', 'users.last_login', 'users.last_name', + 'users.locale', 'users.location_id', 'users.manager_id', 'users.notes', diff --git a/app/Http/Transformers/UsersTransformer.php b/app/Http/Transformers/UsersTransformer.php index 2c01582ddd..f2d1c795fa 100644 --- a/app/Http/Transformers/UsersTransformer.php +++ b/app/Http/Transformers/UsersTransformer.php @@ -27,6 +27,7 @@ class UsersTransformer 'first_name' => e($user->first_name), 'last_name' => e($user->last_name), 'username' => e($user->username), + 'locale' => ($user->locale) ? e($user->locale) : null, 'employee_num' => e($user->employee_num), 'manager' => ($user->manager) ? [ 'id' => (int) $user->manager->id, From 315bcb6b38cbf3caf5c5301d431db6e6f8683a7f Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 23 Apr 2021 14:26:57 -0700 Subject: [PATCH 2/2] Added use statement Signed-off-by: snipe --- app/Http/Controllers/LocationsController.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/LocationsController.php b/app/Http/Controllers/LocationsController.php index e0b7754837..4f07cb05d5 100755 --- a/app/Http/Controllers/LocationsController.php +++ b/app/Http/Controllers/LocationsController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers; use App\Http\Requests\ImageUploadRequest; use App\Models\Location; +use App\Models\User; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Storage; @@ -216,8 +217,8 @@ public function print_assigned($id) $location = Location::where('id',$id)->first(); $parent = Location::where('id',$location->parent_id)->first(); - $manager = User::where('id',$location->manager_id)->first(); - $users = User::where('location_id', $id)->with('company', 'department', 'location')->get(); + $manager = User::where('id',$location->manager_id)->first(); + $users = User::where('location_id', $id)->with('company', 'department', 'location')->get(); $assets = Asset::where('assigned_to', $id)->where('assigned_type', Location::class)->with('model', 'model.category')->get(); return view('locations/print')->with('assets', $assets)->with('users',$users)->with('location', $location)->with('parent', $parent)->with('manager', $manager);