Added #5977: Add permission to view files attached to licenses (#9264)

* Add permission to view and modify files for licenses

* Actually use the permission
This commit is contained in:
Tetrachloromethane250 2021-04-06 05:51:47 +01:00 committed by GitHub
parent 6a8d5282ef
commit 157d9e4ebb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 0 deletions

View file

@ -35,4 +35,14 @@ class LicensePolicy extends CheckoutablePermissionsPolicy
return false; return false;
} }
/**
* Determine whether the user can access files associated with licenses.
*
* @param \App\Models\User $user
* @return mixed
*/
public function files(User $user)
{
return $user->hasAccess($this->columnName().'.files');
}
} }

View file

@ -218,6 +218,12 @@ return array(
'note' => '', 'note' => '',
'display' => true, 'display' => true,
), ),
array(
'permission' => 'licenses.files',
'label' => 'View and Modify License Files',
'note' => '',
'display' => true,
),
), ),

View file

@ -31,7 +31,9 @@
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li class="active"><a href="#details" data-toggle="tab">Details</a></li> <li class="active"><a href="#details" data-toggle="tab">Details</a></li>
<li><a href="#seats" data-toggle="tab">{{ trans('admin/licenses/form.seats') }}</a></li> <li><a href="#seats" data-toggle="tab">{{ trans('admin/licenses/form.seats') }}</a></li>
@can('files', $license)
<li><a href="#uploads" data-toggle="tab">{{ trans('general.file_uploads') }}</a></li> <li><a href="#uploads" data-toggle="tab">{{ trans('general.file_uploads') }}</a></li>
@endcan
<li><a href="#history" data-toggle="tab">{{ trans('admin/licenses/general.checkout_history') }}</a></li> <li><a href="#history" data-toggle="tab">{{ trans('admin/licenses/general.checkout_history') }}</a></li>
<li class="pull-right"><a href="#" data-toggle="modal" data-target="#uploadFileModal"><i class="fa fa-paperclip" aria-hidden="true"></i> {{ trans('button.upload') }}</a></li> <li class="pull-right"><a href="#" data-toggle="modal" data-target="#uploadFileModal"><i class="fa fa-paperclip" aria-hidden="true"></i> {{ trans('button.upload') }}</a></li>
</ul> </ul>
@ -364,6 +366,7 @@
</div> <!--/.row--> </div> <!--/.row-->
</div> <!-- /.tab-pane --> </div> <!-- /.tab-pane -->
@can('files', $license)
<div class="tab-pane" id="uploads"> <div class="tab-pane" id="uploads">
<div class="table-responsive"> <div class="table-responsive">
<table <table
@ -447,6 +450,7 @@
</table> </table>
</div> </div>
</div> <!-- /.tab-pane --> </div> <!-- /.tab-pane -->
@endcan
<div class="tab-pane" id="history"> <div class="tab-pane" id="history">
<div class="row"> <div class="row">