Allow users to update their auto_hold status
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 34s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m51s
Create Docker Image / Final Docker Image Manifest (push) Successful in 9s

This commit is contained in:
Deon George 2024-10-17 16:25:49 +11:00
parent a3719b9186
commit b1560015ae
2 changed files with 10 additions and 4 deletions

View File

@ -488,10 +488,16 @@ class SystemController extends Controller
public function api_autohold_toggle(Request $request,string $state): array public function api_autohold_toggle(Request $request,string $state): array
{ {
$o = System::findOrFail($request->id); $o = System::findOrFail($request->id);
$o->autohold = $state === 'off' ? FALSE : TRUE;
$o->save();
Log::debug(sprintf('%s:- Autohold set to [%s]',self::LOGKEY,$o->autohold ? 'ON' : 'OFF')); if ($request->user()->can('update_nn',$o)) {
$o->autohold = !($state === 'off');
$o->save();
Log::debug(sprintf('%s:- Autohold set to [%s]',self::LOGKEY,$o->autohold ? 'ON' : 'OFF'));
} else {
abort(403);
}
return ['autohold'=>$o->autohold]; return ['autohold'=>$o->autohold];
} }

View File

@ -303,7 +303,7 @@ use App\Models\{Mailer,User};
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<div class="row p-0"> <div class="row p-0">
@can('admin',$o) @can('update_nn',$o)
<div class="col-6"> <div class="col-6">
<label for="autohold" class="form-label">Auto Hold</label> <label for="autohold" class="form-label">Auto Hold</label>
<div class="input-group"> <div class="input-group">