From e1fb446888eeaadae11dbac2f4f30791989ddd66 Mon Sep 17 00:00:00 2001
From: spencerrlongg
Date: Thu, 4 Apr 2024 14:20:03 -0500
Subject: [PATCH 01/71] this is a pretty good start, need to know about other
PR
---
app/Http/Requests/StoreAssetRequest.php | 4 +++
.../Traits/MayContainCustomFields.php | 30 +++++++++++++++++++
2 files changed, 34 insertions(+)
create mode 100644 app/Http/Requests/Traits/MayContainCustomFields.php
diff --git a/app/Http/Requests/StoreAssetRequest.php b/app/Http/Requests/StoreAssetRequest.php
index 8e7559673..587116de4 100644
--- a/app/Http/Requests/StoreAssetRequest.php
+++ b/app/Http/Requests/StoreAssetRequest.php
@@ -2,6 +2,7 @@
namespace App\Http\Requests;
+use App\Http\Requests\Traits\MayContainCustomFields;
use App\Models\Asset;
use App\Models\Company;
use Carbon\Carbon;
@@ -10,6 +11,7 @@ use Illuminate\Support\Facades\Gate;
class StoreAssetRequest extends ImageUploadRequest
{
+ use MayContainCustomFields;
/**
* Determine if the user is authorized to make this request.
*
@@ -36,6 +38,8 @@ class StoreAssetRequest extends ImageUploadRequest
'company_id' => $idForCurrentUser,
'assigned_to' => $assigned_to ?? null,
]);
+
+ //$this->after();
}
/**
diff --git a/app/Http/Requests/Traits/MayContainCustomFields.php b/app/Http/Requests/Traits/MayContainCustomFields.php
new file mode 100644
index 000000000..8acdacb07
--- /dev/null
+++ b/app/Http/Requests/Traits/MayContainCustomFields.php
@@ -0,0 +1,30 @@
+after(function ($validator) {
+ $custom_fields = $this->collect()->keys()->filter(function ($attributes) {
+ return str_starts_with($attributes, '_snipeit_');
+ });
+ if (count($custom_fields) > 0) {
+ if ($this->method() == 'POST') {
+ dd($this->model_id);
+ } elseif ($this->method() == 'PUT' || $this->method() == 'PATCH') {
+ dd($this->asset());
+ }
+ }
+
+ });
+ }
+}
+
From 52340aca783bf0d216e507fd43b7c089805d12d8 Mon Sep 17 00:00:00 2001
From: spencerrlongg
Date: Thu, 4 Apr 2024 17:41:10 -0500
Subject: [PATCH 02/71] just about wrapped up
---
.../Traits/MayContainCustomFields.php | 22 ++++++++++---------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/app/Http/Requests/Traits/MayContainCustomFields.php b/app/Http/Requests/Traits/MayContainCustomFields.php
index 8acdacb07..5a3299b36 100644
--- a/app/Http/Requests/Traits/MayContainCustomFields.php
+++ b/app/Http/Requests/Traits/MayContainCustomFields.php
@@ -2,25 +2,27 @@
namespace App\Http\Requests\Traits;
+use App\Models\AssetModel;
+
trait MayContainCustomFields
{
- //public function after()
- //{
- // dd($this);
- // $request_data = $this;
- //}
-
+ // this gets called automatically on a form request
public function withValidator($validator)
{
$validator->after(function ($validator) {
- $custom_fields = $this->collect()->keys()->filter(function ($attributes) {
+ $request_fields = $this->collect()->keys()->filter(function ($attributes) {
return str_starts_with($attributes, '_snipeit_');
});
- if (count($custom_fields) > 0) {
+ if (count($request_fields) > 0) {
if ($this->method() == 'POST') {
- dd($this->model_id);
+ $request_fields->diff(AssetModel::find($this->model_id)->fieldset->fields->pluck('db_column'))
+ ->each(function ($request_field_name) use ($request_fields, $validator) {
+ // i could probably add some more conditions here to determine whether or not the column exists but just not on this asset model
+ // and then return a more helpful error message
+ $validator->errors()->add($request_field_name, 'This field does not seem to exist (at least on this asset), please double check your custom field names.');
+ });
} elseif ($this->method() == 'PUT' || $this->method() == 'PATCH') {
- dd($this->asset());
+ // need to know about other pr before I can go down this route
}
}
From 997eddfed1bda9d6559b9d7604f0cde1ddc7a7aa Mon Sep 17 00:00:00 2001
From: spencerrlongg
Date: Thu, 4 Apr 2024 18:23:03 -0500
Subject: [PATCH 03/71] cleanup + notes for monday
---
app/Http/Requests/StoreAssetRequest.php | 2 --
app/Http/Requests/Traits/MayContainCustomFields.php | 5 ++++-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/app/Http/Requests/StoreAssetRequest.php b/app/Http/Requests/StoreAssetRequest.php
index 587116de4..b00baf90f 100644
--- a/app/Http/Requests/StoreAssetRequest.php
+++ b/app/Http/Requests/StoreAssetRequest.php
@@ -38,8 +38,6 @@ class StoreAssetRequest extends ImageUploadRequest
'company_id' => $idForCurrentUser,
'assigned_to' => $assigned_to ?? null,
]);
-
- //$this->after();
}
/**
diff --git a/app/Http/Requests/Traits/MayContainCustomFields.php b/app/Http/Requests/Traits/MayContainCustomFields.php
index 5a3299b36..a506412fe 100644
--- a/app/Http/Requests/Traits/MayContainCustomFields.php
+++ b/app/Http/Requests/Traits/MayContainCustomFields.php
@@ -15,6 +15,7 @@ trait MayContainCustomFields
});
if (count($request_fields) > 0) {
if ($this->method() == 'POST') {
+ // refactor to eager load the fields???
$request_fields->diff(AssetModel::find($this->model_id)->fieldset->fields->pluck('db_column'))
->each(function ($request_field_name) use ($request_fields, $validator) {
// i could probably add some more conditions here to determine whether or not the column exists but just not on this asset model
@@ -23,9 +24,11 @@ trait MayContainCustomFields
});
} elseif ($this->method() == 'PUT' || $this->method() == 'PATCH') {
// need to know about other pr before I can go down this route
+ // it should be more or less the same, just have to get the asset model differently
+ // ($this->asset should work if the other PR is accepted)
+ return;
}
}
-
});
}
}
From f30439a54408e3564b3f23f229950a697478abf4 Mon Sep 17 00:00:00 2001
From: spencerrlongg
Date: Sun, 7 Apr 2024 17:07:46 -0500
Subject: [PATCH 04/71] small refactor, pretty much good to go now though
---
.../Traits/MayContainCustomFields.php | 31 +++++++++++--------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/app/Http/Requests/Traits/MayContainCustomFields.php b/app/Http/Requests/Traits/MayContainCustomFields.php
index a506412fe..206217221 100644
--- a/app/Http/Requests/Traits/MayContainCustomFields.php
+++ b/app/Http/Requests/Traits/MayContainCustomFields.php
@@ -3,31 +3,36 @@
namespace App\Http\Requests\Traits;
use App\Models\AssetModel;
+use App\Models\CustomField;
trait MayContainCustomFields
{
// this gets called automatically on a form request
public function withValidator($validator)
{
- $validator->after(function ($validator) {
+ // find the model
+ if ($this->method() == 'POST') {
+ $asset_model = AssetModel::find($this->model_id);
+ }
+ if ($this->method() == 'PATCH' || $this->method() == 'PUT') {
+ // this is dependent on the asset update request PR
+ $asset_model = $this->asset;
+ }
+ // collect the custom fields in the request
+ $validator->after(function ($validator) use ($asset_model) {
$request_fields = $this->collect()->keys()->filter(function ($attributes) {
return str_starts_with($attributes, '_snipeit_');
});
+ // if there are custom fields, find the one's that don't exist on the model's fieldset and add an error to the validator's error bag
if (count($request_fields) > 0) {
- if ($this->method() == 'POST') {
- // refactor to eager load the fields???
- $request_fields->diff(AssetModel::find($this->model_id)->fieldset->fields->pluck('db_column'))
+ $request_fields->diff($asset_model->fieldset->fields->pluck('db_column'))
->each(function ($request_field_name) use ($request_fields, $validator) {
- // i could probably add some more conditions here to determine whether or not the column exists but just not on this asset model
- // and then return a more helpful error message
- $validator->errors()->add($request_field_name, 'This field does not seem to exist (at least on this asset), please double check your custom field names.');
+ if (CustomField::where('db_column', $request_field_name)->exists()) {
+ $validator->errors()->add($request_field_name, 'This field seems to exist, but is not available on this Asset Model\'s fieldset.');
+ } else {
+ $validator->errors()->add($request_field_name, 'This field does not seem to exist, please double check your custom field names.');
+ }
});
- } elseif ($this->method() == 'PUT' || $this->method() == 'PATCH') {
- // need to know about other pr before I can go down this route
- // it should be more or less the same, just have to get the asset model differently
- // ($this->asset should work if the other PR is accepted)
- return;
- }
}
});
}
From 99d7155729b4dc9d1412b9e7f459d4b6086e6dfa Mon Sep 17 00:00:00 2001
From: spencerrlongg
Date: Sun, 7 Apr 2024 19:50:53 -0500
Subject: [PATCH 05/71] translation strings
---
app/Http/Requests/Traits/MayContainCustomFields.php | 4 ++--
resources/lang/en-US/validation.php | 3 ++-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/app/Http/Requests/Traits/MayContainCustomFields.php b/app/Http/Requests/Traits/MayContainCustomFields.php
index 206217221..50b239b60 100644
--- a/app/Http/Requests/Traits/MayContainCustomFields.php
+++ b/app/Http/Requests/Traits/MayContainCustomFields.php
@@ -28,9 +28,9 @@ trait MayContainCustomFields
$request_fields->diff($asset_model->fieldset->fields->pluck('db_column'))
->each(function ($request_field_name) use ($request_fields, $validator) {
if (CustomField::where('db_column', $request_field_name)->exists()) {
- $validator->errors()->add($request_field_name, 'This field seems to exist, but is not available on this Asset Model\'s fieldset.');
+ $validator->errors()->add($request_field_name, trans('validation.custom.custom_field_not_found_on_model'));
} else {
- $validator->errors()->add($request_field_name, 'This field does not seem to exist, please double check your custom field names.');
+ $validator->errors()->add($request_field_name, trans('validation.custom.custom_field_not_found'));
}
});
}
diff --git a/resources/lang/en-US/validation.php b/resources/lang/en-US/validation.php
index 05374e23a..630816354 100644
--- a/resources/lang/en-US/validation.php
+++ b/resources/lang/en-US/validation.php
@@ -126,6 +126,8 @@ return [
'hashed_pass' => 'Your current password is incorrect',
'dumbpwd' => 'That password is too common.',
'statuslabel_type' => 'You must select a valid status label type',
+ 'custom_field_not_found' => 'This field does not seem to exist, please double check your custom field names.',
+ 'custom_field_not_found_on_model' => 'This field seems to exist, but is not available on this Asset Model\'s fieldset.',
// date_format validation with slightly less stupid messages. It duplicates a lot, but it gets the job done :(
// We use this because the default error message for date_format is reflects php Y-m-d, which non-PHP
@@ -137,7 +139,6 @@ return [
'expected_checkin.date_format' => 'The :attribute must be a valid date in YYYY-MM-DD format',
'start_date.date_format' => 'The :attribute must be a valid date in YYYY-MM-DD format',
'end_date.date_format' => 'The :attribute must be a valid date in YYYY-MM-DD format',
-
],
/*
From 750015684d04cc3422df30018dd3c65e30a81f66 Mon Sep 17 00:00:00 2001
From: Godfrey M
Date: Tue, 23 Jul 2024 10:42:50 -0700
Subject: [PATCH 06/71] purges user storage files
---
app/Console/Commands/Purge.php | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/app/Console/Commands/Purge.php b/app/Console/Commands/Purge.php
index 7abd83c85..8922519c2 100644
--- a/app/Console/Commands/Purge.php
+++ b/app/Console/Commands/Purge.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands;
use App\Models\Accessory;
+use App\Models\Actionlog;
use App\Models\Asset;
use App\Models\AssetModel;
use App\Models\Category;
@@ -15,6 +16,7 @@ use App\Models\Statuslabel;
use App\Models\Supplier;
use App\Models\User;
use Illuminate\Console\Command;
+use Illuminate\Support\Facades\Storage;
class Purge extends Command
{
@@ -141,6 +143,15 @@ class Purge extends Command
$this->info($users->count().' users purged.');
$user_assoc = 0;
foreach ($users as $user) {
+ $rel_path = 'private_uploads/users';
+ $filenames = Actionlog::where('action_type', 'uploaded')
+ ->where('item_id', $user->id)
+ ->pluck('filename');
+ foreach($filenames as $filename) {
+ if (Storage::exists($rel_path.'/'.$filename)) {
+ Storage::delete($rel_path . '/' . $filename);
+ }
+ }
$this->info('- User "'.$user->username.'" deleted.');
$user_assoc += $user->userlog()->count();
$user->userlog()->forceDelete();
From 869c06f454a06243abd8b9f33f7482ebe07288dd Mon Sep 17 00:00:00 2001
From: Marcus Moore
Date: Tue, 23 Jul 2024 15:41:58 -0700
Subject: [PATCH 07/71] Register anonymous blade component namespace
---
app/Providers/BladeServiceProvider.php | 25 +++++++++++++++++++++++++
config/app.php | 1 +
resources/views/blade/example.blade.php | 3 +++
3 files changed, 29 insertions(+)
create mode 100644 app/Providers/BladeServiceProvider.php
create mode 100644 resources/views/blade/example.blade.php
diff --git a/app/Providers/BladeServiceProvider.php b/app/Providers/BladeServiceProvider.php
new file mode 100644
index 000000000..024ee9d3d
--- /dev/null
+++ b/app/Providers/BladeServiceProvider.php
@@ -0,0 +1,25 @@
+
+ Hi.
+
From 5b8529bc83b6e8b6fef7c014bd059715dbb7b52d Mon Sep 17 00:00:00 2001
From: snipe
Date: Wed, 24 Jul 2024 19:16:08 +0100
Subject: [PATCH 08/71] Fixed pluralization
Signed-off-by: snipe
---
resources/lang/si-LK/general.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/resources/lang/si-LK/general.php b/resources/lang/si-LK/general.php
index 4c0d64fd9..0063808f9 100644
--- a/resources/lang/si-LK/general.php
+++ b/resources/lang/si-LK/general.php
@@ -556,7 +556,7 @@ return [
'something_went_wrong' => 'Something went wrong with your request.',
'close' => 'Close',
'expires' => 'Expires',
- 'map_fields'=> 'Map :item_type Field',
+ 'map_fields'=> 'Map :item_type Fields',
'remaining_var' => ':count Remaining',
];
From 63f0b5279d950092d9aa8f451dcb032809132828 Mon Sep 17 00:00:00 2001
From: snipe
Date: Wed, 24 Jul 2024 20:13:01 +0100
Subject: [PATCH 09/71] Added check for purchase_date
Signed-off-by: snipe
---
app/Models/License.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/Models/License.php b/app/Models/License.php
index d8bc3f03b..2680424a8 100755
--- a/app/Models/License.php
+++ b/app/Models/License.php
@@ -50,7 +50,7 @@ class License extends Depreciable
'category_id' => 'required|exists:categories,id',
'company_id' => 'integer|nullable',
'purchase_cost'=> 'numeric|nullable|gte:0',
- 'purchase_date' => 'date_format:Y-m-d|nullable|max:10',
+ 'purchase_date' => 'date_format:Y-m-d|nullable|max:10|required_with:depreciation_id',
'expiration_date' => 'date_format:Y-m-d|nullable|max:10',
'termination_date' => 'date_format:Y-m-d|nullable|max:10',
'min_amt' => 'numeric|nullable|gte:0',
From adf58a06da86bca9a1320be636b199ae0fa20a32 Mon Sep 17 00:00:00 2001
From: snipe
Date: Wed, 24 Jul 2024 20:13:11 +0100
Subject: [PATCH 10/71] Added check for purchase date
Signed-off-by: snipe
---
app/Models/Depreciable.php | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/app/Models/Depreciable.php b/app/Models/Depreciable.php
index 721135873..6139cda08 100644
--- a/app/Models/Depreciable.php
+++ b/app/Models/Depreciable.php
@@ -158,17 +158,20 @@ class Depreciable extends SnipeModel
public function time_until_depreciated()
{
- // @link http://www.php.net/manual/en/class.datetime.php
- $d1 = new \DateTime();
- $d2 = $this->depreciated_date();
+ if ($this->depreciated_date()) {
+ // @link http://www.php.net/manual/en/class.datetime.php
+ $d1 = new \DateTime();
+ $d2 = $this->depreciated_date();
- // @link http://www.php.net/manual/en/class.dateinterval.php
- $interval = $d1->diff($d2);
- if (! $interval->invert) {
- return $interval;
- } else {
- return new \DateInterval('PT0S'); //null interval (zero seconds from now)
+ // @link http://www.php.net/manual/en/class.dateinterval.php
+ $interval = $d1->diff($d2);
+ if (! $interval->invert) {
+ return $interval;
+ } else {
+ return new \DateInterval('PT0S'); //null interval (zero seconds from now)
+ }
}
+ return false;
}
public function depreciated_date()
From ef145e47b45d9601e23d5c317bdb28f555b71ef9 Mon Sep 17 00:00:00 2001
From: snipe
Date: Wed, 24 Jul 2024 20:13:15 +0100
Subject: [PATCH 11/71] Added tests
Signed-off-by: snipe
---
.../Feature/Licenses/Ui/CreateLicenseTest.php | 42 +++++++++++++++++++
tests/Feature/Licenses/Ui/LicenseViewTest.php | 41 ++++++++++++++++++
2 files changed, 83 insertions(+)
create mode 100644 tests/Feature/Licenses/Ui/CreateLicenseTest.php
create mode 100644 tests/Feature/Licenses/Ui/LicenseViewTest.php
diff --git a/tests/Feature/Licenses/Ui/CreateLicenseTest.php b/tests/Feature/Licenses/Ui/CreateLicenseTest.php
new file mode 100644
index 000000000..f24c3bd2c
--- /dev/null
+++ b/tests/Feature/Licenses/Ui/CreateLicenseTest.php
@@ -0,0 +1,42 @@
+create();
+ $this->actingAs(User::factory()->create())
+ ->get(route('licenses.create', $license))
+ ->assertForbidden();
+ }
+
+
+
+ public function testLicenseWithoutPurchaseDateFailsValidation()
+ {
+ $response = $this->actingAs(User::factory()->superuser()->create())
+ ->from(route('licenses.create'))
+ ->post(route('licenses.store'), [
+ 'name' => 'Test Invalid License',
+ 'seats' => '10',
+ 'category_id' => Category::factory()->forLicenses()->create()->id,
+ 'depreciation_id' => Depreciation::factory()->create()->id
+ ]);
+ $response->assertStatus(302);
+ $response->assertRedirect(route('licenses.create'));
+ $response->assertInvalid(['purchase_date']);
+ $response->assertSessionHasErrors(['purchase_date']);
+ $this->followRedirects($response)->assertSee(trans('general.error'));
+ $this->assertFalse(AssetModel::where('name', 'Test Invalid License')->exists());
+
+ }
+}
diff --git a/tests/Feature/Licenses/Ui/LicenseViewTest.php b/tests/Feature/Licenses/Ui/LicenseViewTest.php
new file mode 100644
index 000000000..295b23c5f
--- /dev/null
+++ b/tests/Feature/Licenses/Ui/LicenseViewTest.php
@@ -0,0 +1,41 @@
+create();
+ $this->actingAs(User::factory()->create())
+ ->get(route('licenses.show', $license))
+ ->assertForbidden();
+ }
+
+
+ public function testLicenseWithNoPurchaseDateDoesNotTriggerDepreciation()
+ {
+ $depreciation = Depreciation::factory()->create(['months' => 12]);
+ $license = License::factory()->create(['depreciation_id' => $depreciation->id, 'purchase_date' => null]);
+ $this->actingAs(User::factory()->superuser()->create())
+ ->get(route('licenses.show', $license))
+ ->assertOk();
+ }
+
+ public function testLicenseWithPurchaseDateDepreciatesCorrectly()
+ {
+ $depreciation = Depreciation::factory()->create(['months' => 12]);
+ $license = License::factory()->create(['depreciation_id' => $depreciation->id, 'purchase_date' => '2020-01-01']);
+ $this->actingAs(User::factory()->superuser()->create())
+ ->get(route('licenses.show', $license))
+ ->assertOk()
+ ->assertSee([
+ '2021-01-01'
+ ], false);
+ }
+}
From da4ec145d764cdbcc4557e0af74f9ede8157312a Mon Sep 17 00:00:00 2001
From: snipe
Date: Wed, 24 Jul 2024 20:17:30 +0100
Subject: [PATCH 12/71] Removed test no longer needed due to validation
Signed-off-by: snipe
---
tests/Feature/Licenses/Ui/LicenseViewTest.php | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/tests/Feature/Licenses/Ui/LicenseViewTest.php b/tests/Feature/Licenses/Ui/LicenseViewTest.php
index 295b23c5f..3b1f7830d 100644
--- a/tests/Feature/Licenses/Ui/LicenseViewTest.php
+++ b/tests/Feature/Licenses/Ui/LicenseViewTest.php
@@ -16,17 +16,7 @@ class LicenseViewTest extends TestCase
->get(route('licenses.show', $license))
->assertForbidden();
}
-
-
- public function testLicenseWithNoPurchaseDateDoesNotTriggerDepreciation()
- {
- $depreciation = Depreciation::factory()->create(['months' => 12]);
- $license = License::factory()->create(['depreciation_id' => $depreciation->id, 'purchase_date' => null]);
- $this->actingAs(User::factory()->superuser()->create())
- ->get(route('licenses.show', $license))
- ->assertOk();
- }
-
+
public function testLicenseWithPurchaseDateDepreciatesCorrectly()
{
$depreciation = Depreciation::factory()->create(['months' => 12]);
From c3a2cdeee9684ca23ff6b25cd602b63b31b7646d Mon Sep 17 00:00:00 2001
From: snipe
Date: Wed, 24 Jul 2024 20:53:58 +0100
Subject: [PATCH 13/71] Added assets endpoint for locations
Signed-off-by: snipe
---
.../Controllers/Api/LocationsController.php | 11 ++++++
routes/api.php | 2 +-
.../Locations/Api/LocationsViewTest.php | 36 +++++++++++++++++++
3 files changed, 48 insertions(+), 1 deletion(-)
create mode 100644 tests/Feature/Locations/Api/LocationsViewTest.php
diff --git a/app/Http/Controllers/Api/LocationsController.php b/app/Http/Controllers/Api/LocationsController.php
index 2ceeb8374..73227e082 100644
--- a/app/Http/Controllers/Api/LocationsController.php
+++ b/app/Http/Controllers/Api/LocationsController.php
@@ -5,8 +5,10 @@ namespace App\Http\Controllers\Api;
use App\Helpers\Helper;
use App\Http\Requests\ImageUploadRequest;
use App\Http\Controllers\Controller;
+use App\Http\Transformers\AssetsTransformer;
use App\Http\Transformers\LocationsTransformer;
use App\Http\Transformers\SelectlistTransformer;
+use App\Models\Asset;
use App\Models\Location;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
@@ -222,6 +224,15 @@ class LocationsController extends Controller
return response()->json(Helper::formatStandardApiResponse('error', null, $location->getErrors()));
}
+ public function assets(Request $request, Location $location) : JsonResponse | array
+ {
+ $this->authorize('view', Asset::class);
+ $this->authorize('view', $location);
+ $assets = Asset::where('assigned_to', '=', $location->id)->where('assigned_type', '=', Location::class)->with('model', 'model.category', 'assetstatus', 'location', 'company', 'defaultLoc');
+ $assets = $assets->get();
+ return (new AssetsTransformer)->transformAssets($assets, $assets->count(), $request);
+ }
+
/**
* Remove the specified resource from storage.
*
diff --git a/routes/api.php b/routes/api.php
index b5311aa98..9fffd7566 100644
--- a/routes/api.php
+++ b/routes/api.php
@@ -712,7 +712,7 @@ Route::group(['prefix' => 'v1', 'middleware' => ['api', 'throttle:api']], functi
Route::get('{location}/assets',
[
Api\LocationsController::class,
- 'getDataViewAssets'
+ 'assets'
]
)->name('api.locations.viewassets');
diff --git a/tests/Feature/Locations/Api/LocationsViewTest.php b/tests/Feature/Locations/Api/LocationsViewTest.php
new file mode 100644
index 000000000..b5bcff8e4
--- /dev/null
+++ b/tests/Feature/Locations/Api/LocationsViewTest.php
@@ -0,0 +1,36 @@
+create();
+ $this->actingAsForApi(User::factory()->create())
+ ->getJson(route('api.locations.show', $location->id))
+ ->assertForbidden();
+ }
+
+ public function testViewingLocationAssetIndexRequiresPermission()
+ {
+ $location = Location::factory()->create();
+ Asset::factory()->count(3)->assignedToLocation($location)->create();
+
+ $this->actingAsForApi(User::factory()->superuser()->create())
+ ->getJson(route('api.locations.viewassets', $location->id))
+ ->assertOk()
+ ->assertJsonStructure([
+ 'total',
+ 'rows',
+ ])
+ ->assertJson([
+ 'total' => 3,
+ ]);
+ }
+}
From 590d13061a64b4e78a7e6b57468d56153a13833b Mon Sep 17 00:00:00 2001
From: snipe
Date: Wed, 24 Jul 2024 20:57:26 +0100
Subject: [PATCH 14/71] One more test
Signed-off-by: snipe
---
tests/Feature/Locations/Api/LocationsViewTest.php | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tests/Feature/Locations/Api/LocationsViewTest.php b/tests/Feature/Locations/Api/LocationsViewTest.php
index b5bcff8e4..1d57e5826 100644
--- a/tests/Feature/Locations/Api/LocationsViewTest.php
+++ b/tests/Feature/Locations/Api/LocationsViewTest.php
@@ -18,6 +18,14 @@ class LocationsViewTest extends TestCase
}
public function testViewingLocationAssetIndexRequiresPermission()
+ {
+ $location = Location::factory()->create();
+ $this->actingAsForApi(User::factory()->create())
+ ->getJson(route('api.locations.viewassets', $location->id))
+ ->assertForbidden();
+ }
+
+ public function testViewingLocationAssetIndex()
{
$location = Location::factory()->create();
Asset::factory()->count(3)->assignedToLocation($location)->create();
From 9b422e5c974d80a76a35376a78d02b48b27c0978 Mon Sep 17 00:00:00 2001
From: snipe
Date: Wed, 24 Jul 2024 21:42:20 +0100
Subject: [PATCH 15/71] Baremetrics BMPay breaks with CSP turned [sc-25011]
Signed-off-by: snipe
---
config/services.php | 6 ------
resources/views/layouts/default.blade.php | 3 ---
resources/views/partials/bpay.blade.php | 15 ---------------
3 files changed, 24 deletions(-)
delete mode 100644 resources/views/partials/bpay.blade.php
diff --git a/config/services.php b/config/services.php
index 21acb6778..07b1c1069 100644
--- a/config/services.php
+++ b/config/services.php
@@ -44,12 +44,6 @@ return [
'secret' => env('STRIPE_SECRET'),
],
- 'baremetrics' => [
- 'enabled' => env('ENABLE_BMPAY', false),
- 'app_key' => env('BMPAY_PUBLIC_KEY', null),
- 'stripe_id' => env('BMPAY_STRIPE_ID', null),
- ],
-
'google' => [
'maps_api_key' => env('GOOGLE_MAPS_API'),
],
diff --git a/resources/views/layouts/default.blade.php b/resources/views/layouts/default.blade.php
index ee235d358..839d76905 100644
--- a/resources/views/layouts/default.blade.php
+++ b/resources/views/layouts/default.blade.php
@@ -1136,8 +1136,5 @@ dir="{{ Helper::determineLanguageDirection() }}">
@endif
- @include('partials.bpay')
-
-