mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-02 08:21:09 -08:00
Add redirect for missing template
This commit is contained in:
parent
ee00699cb3
commit
c881727747
|
@ -4,7 +4,6 @@ namespace App\Http\Controllers;
|
|||
|
||||
use App\Models\CustomField;
|
||||
use App\Models\ReportTemplate;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
@ -47,13 +46,20 @@ class ReportTemplatesController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
public function edit($reportId): View
|
||||
public function edit($reportId)
|
||||
{
|
||||
$this->authorize('reports.view');
|
||||
|
||||
$reportTemplate = ReportTemplate::find($reportId);
|
||||
|
||||
if (!$reportTemplate) {
|
||||
return redirect()->route('reports/custom')
|
||||
->with('error', trans('admin/reports/message.no_report_permission'));
|
||||
}
|
||||
|
||||
return view('reports/custom', [
|
||||
'customfields' => CustomField::get(),
|
||||
'template' => ReportTemplate::findOrFail($reportId),
|
||||
'template' => $reportTemplate,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,8 +18,6 @@ class EditReportTemplateTest extends TestCase implements TestsPermissionsRequire
|
|||
|
||||
public function testCannotLoadEditPageForAnotherUsersReportTemplate()
|
||||
{
|
||||
$this->markTestIncomplete('Returns 404...');
|
||||
|
||||
$user = User::factory()->canViewReports()->create();
|
||||
$reportTemplate = ReportTemplate::factory()->create();
|
||||
|
||||
|
|
Loading…
Reference in a new issue