Merge branch 'develop'
# Conflicts: # config/version.php
This commit is contained in:
commit
01eaf48471
35 changed files with 243 additions and 26 deletions
|
@ -190,7 +190,13 @@ class LdapSync extends Command
|
|||
if ($item['ldap_location_override'] == true) {
|
||||
$user->location_id = $item['location_id'];
|
||||
} elseif ((isset($location)) && (!empty($location))) {
|
||||
$user->location_id = e($location->id);
|
||||
|
||||
if ((is_array($location)) && (array_key_exists('id', $location))) {
|
||||
$user->location_id = $location['id'];
|
||||
} elseif (is_object($location)) {
|
||||
$user->location_id = $location->id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$user->notes = 'Imported from LDAP';
|
||||
|
|
|
@ -235,7 +235,7 @@ class Helper
|
|||
*/
|
||||
public static function statusLabelList()
|
||||
{
|
||||
$statuslabel_list = array('' => trans('general.select_statuslabel')) + Statuslabel::orderBy('deployable', 'desc')
|
||||
$statuslabel_list = array('' => trans('general.select_statuslabel')) + Statuslabel::orderBy('default_label', 'desc')->orderBy('name','asc')->orderBy('deployable','desc')
|
||||
->pluck('name', 'id')->toArray();
|
||||
return $statuslabel_list;
|
||||
}
|
||||
|
|
|
@ -420,7 +420,7 @@ class AssetsController extends Controller
|
|||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$this->authorize('create', Asset::class);
|
||||
$this->authorize('edit', Asset::class);
|
||||
|
||||
if ($asset = Asset::find($id)) {
|
||||
($request->has('model_id')) ?
|
||||
|
|
|
@ -22,7 +22,7 @@ class StatuslabelsController extends Controller
|
|||
public function index(Request $request)
|
||||
{
|
||||
$this->authorize('view', Statuslabel::class);
|
||||
$allowed_columns = ['id','name','created_at', 'assets_count','color'];
|
||||
$allowed_columns = ['id','name','created_at', 'assets_count','color','default_label'];
|
||||
|
||||
$statuslabels = Statuslabel::withCount('assets');
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@ class AssetModelsController extends Controller
|
|||
*/
|
||||
public function edit($modelId = null)
|
||||
{
|
||||
$this->authorize('edit', AssetModel::class);
|
||||
$this->authorize('update', AssetModel::class);
|
||||
if ($item = AssetModel::find($modelId)) {
|
||||
$category_type = 'asset';
|
||||
$view = View::make('models/edit', compact('item','category_type'));
|
||||
|
@ -190,7 +190,7 @@ class AssetModelsController extends Controller
|
|||
*/
|
||||
public function update(ImageUploadRequest $request, $modelId = null)
|
||||
{
|
||||
$this->authorize('edit', AssetModel::class);
|
||||
$this->authorize('update', AssetModel::class);
|
||||
// Check if the model exists
|
||||
if (is_null($model = AssetModel::find($modelId))) {
|
||||
// Redirect to the models management page
|
||||
|
|
|
@ -93,9 +93,9 @@ class StatuslabelsController extends Controller
|
|||
$statusLabel->archived = $statusType['archived'];
|
||||
$statusLabel->color = Input::get('color');
|
||||
$statusLabel->show_in_nav = Input::get('show_in_nav', 0);
|
||||
$statusLabel->default_label = Input::get('default_label', 0);
|
||||
|
||||
|
||||
// Was the asset created?
|
||||
if ($statusLabel->save()) {
|
||||
// Redirect to the new Statuslabel page
|
||||
return redirect()->route('statuslabels.index')->with('success', trans('admin/statuslabels/message.create.success'));
|
||||
|
@ -185,6 +185,7 @@ class StatuslabelsController extends Controller
|
|||
$statuslabel->archived = $statustype['archived'];
|
||||
$statuslabel->color = Input::get('color');
|
||||
$statuslabel->show_in_nav = Input::get('show_in_nav', 0);
|
||||
$statuslabel->default_label = Input::get('default_label', 0);
|
||||
|
||||
|
||||
// Was the asset created?
|
||||
|
|
|
@ -26,6 +26,7 @@ class CustomFieldsTransformer
|
|||
'name' => e($field->name),
|
||||
'db_column_name' => e($field->db_column_name()),
|
||||
'format' => e($field->format),
|
||||
'field_values' => ($field->field_values) ? e($field->field_values) : null,
|
||||
'required' => $field->pivot ? $field->pivot->required : false,
|
||||
'created_at' => Helper::getFormattedDateObject($field->created_at, 'datetime'),
|
||||
'updated_at' => Helper::getFormattedDateObject($field->updated_at, 'datetime'),
|
||||
|
|
|
@ -26,6 +26,7 @@ class StatuslabelsTransformer
|
|||
'type' => $statuslabel->getStatuslabelType(),
|
||||
'color' => ($statuslabel->color) ? e($statuslabel->color) : null,
|
||||
'show_in_nav' => ($statuslabel->show_in_nav=='1') ? true : false,
|
||||
'default_label' => ($statuslabel->default_label =='1') ? true : false,
|
||||
'assets_count' => (int) $statuslabel->assets_count,
|
||||
'notes' => e($statuslabel->notes),
|
||||
'created_at' => Helper::getFormattedDateObject($statuslabel->created_at, 'datetime'),
|
||||
|
|
|
@ -346,7 +346,10 @@ class User extends SnipeModel implements AuthenticatableContract, CanResetPasswo
|
|||
$username = str_slug(substr($first_name, 0, 1).$last_name);
|
||||
|
||||
if ($format=='firstname.lastname') {
|
||||
$username = str_slug($first_name).'.'.str_slug($last_name);
|
||||
$username = str_slug($first_name) . '.' . str_slug($last_name);
|
||||
|
||||
} elseif ($format=='lastnamefirstinitial') {
|
||||
$username = str_slug($last_name.substr($first_name, 0, 1));
|
||||
|
||||
} elseif ($format=='firstname_lastname') {
|
||||
$username = str_slug($first_name).'_'.str_slug($last_name);
|
||||
|
|
13
app/Policies/DepreciationPolicy.php
Normal file
13
app/Policies/DepreciationPolicy.php
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Policies\SnipePermissionsPolicy;
|
||||
|
||||
class DepreciationPolicy extends SnipePermissionsPolicy
|
||||
{
|
||||
protected function columnName()
|
||||
{
|
||||
return 'depreciations';
|
||||
}
|
||||
}
|
|
@ -12,6 +12,7 @@ use App\Models\CustomField;
|
|||
use App\Models\Department;
|
||||
use App\Models\License;
|
||||
use App\Models\Location;
|
||||
use App\Models\Depreciation;
|
||||
use App\Models\Statuslabel;
|
||||
use App\Models\Supplier;
|
||||
use App\Models\Manufacturer;
|
||||
|
@ -25,6 +26,7 @@ use App\Policies\ComponentPolicy;
|
|||
use App\Policies\ConsumablePolicy;
|
||||
use App\Policies\CustomFieldPolicy;
|
||||
use App\Policies\DepartmentPolicy;
|
||||
use App\Policies\DepreciationPolicy;
|
||||
use App\Policies\LicensePolicy;
|
||||
use App\Policies\LocationPolicy;
|
||||
use App\Policies\StatuslabelPolicy;
|
||||
|
@ -55,6 +57,7 @@ class AuthServiceProvider extends ServiceProvider
|
|||
Consumable::class => ConsumablePolicy::class,
|
||||
CustomField::class => CustomFieldPolicy::class,
|
||||
Department::class => DepartmentPolicy::class,
|
||||
Depreciation::class => DepreciationPolicy::class,
|
||||
License::class => LicensePolicy::class,
|
||||
Location::class => LocationPolicy::class,
|
||||
Statuslabel::class => StatuslabelPolicy::class,
|
||||
|
@ -130,17 +133,17 @@ class AuthServiceProvider extends ServiceProvider
|
|||
});
|
||||
|
||||
Gate::define('backend.interact', function ($user) {
|
||||
return $user->can('view', \App\Models\Statuslabel::class)
|
||||
|| $user->can('view', \App\Models\AssetModel::class)
|
||||
|| $user->can('view', \App\Models\Category::class)
|
||||
|| $user->can('view', \App\Models\Manufacturer::class)
|
||||
|| $user->can('view', \App\Models\Supplier::class)
|
||||
|| $user->can('view', \App\Models\Department::class)
|
||||
|| $user->can('view', \App\Models\Location::class)
|
||||
|| $user->can('view', \App\Models\Company::class)
|
||||
|| $user->can('view', \App\Models\Manufacturer::class)
|
||||
|| $user->can('view', \App\Models\Company::class)
|
||||
|| $user->can('view', \App\Models\Depreciation::class);
|
||||
return $user->can('view', Statuslabel::class)
|
||||
|| $user->can('view', AssetModel::class)
|
||||
|| $user->can('view', Category::class)
|
||||
|| $user->can('view', Manufacturer::class)
|
||||
|| $user->can('view', Supplier::class)
|
||||
|| $user->can('view', Department::class)
|
||||
|| $user->can('view', Location::class)
|
||||
|| $user->can('view', Company::class)
|
||||
|| $user->can('view', Manufacturer::class)
|
||||
|| $user->can('view', CustomField::class)
|
||||
|| $user->can('view', Depreciation::class);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DO NOT EDIT THIS FILE DIRECTLY.
|
||||
|--------------------------------------------------------------------------
|
||||
| This file reads from your .env configuration file and should not
|
||||
| be modified directly.
|
||||
*/
|
||||
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DO NOT EDIT THIS FILE DIRECTLY.
|
||||
|--------------------------------------------------------------------------
|
||||
| This file reads from your .env configuration file and should not
|
||||
| be modified directly.
|
||||
*/
|
||||
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,5 +1,15 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DO NOT EDIT THIS FILE DIRECTLY.
|
||||
|--------------------------------------------------------------------------
|
||||
| This file reads from your .env configuration file and should not
|
||||
| be modified directly.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,5 +1,15 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DO NOT EDIT THIS FILE DIRECTLY.
|
||||
|--------------------------------------------------------------------------
|
||||
| This file reads from your .env configuration file and should not
|
||||
| be modified directly.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,5 +1,15 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DO NOT EDIT THIS FILE DIRECTLY.
|
||||
|--------------------------------------------------------------------------
|
||||
| This file reads from your .env configuration file and should not
|
||||
| be modified directly.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DO NOT EDIT THIS FILE DIRECTLY.
|
||||
|--------------------------------------------------------------------------
|
||||
| This file reads from your .env configuration file and should not
|
||||
| be modified directly.
|
||||
*/
|
||||
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DO NOT EDIT THIS FILE DIRECTLY.
|
||||
|--------------------------------------------------------------------------
|
||||
| This file reads from your .env configuration file and should not
|
||||
| be modified directly.
|
||||
*/
|
||||
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DO NOT EDIT THIS FILE DIRECTLY.
|
||||
|--------------------------------------------------------------------------
|
||||
| This file reads from your .env configuration file and should not
|
||||
| be modified directly.
|
||||
*/
|
||||
|
||||
|
||||
return array(
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DO NOT EDIT THIS FILE DIRECTLY.
|
||||
|--------------------------------------------------------------------------
|
||||
| This file reads from your .env configuration file and should not
|
||||
| be modified directly.
|
||||
*/
|
||||
|
||||
|
||||
return [
|
||||
|
||||
'backup' => [
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DO NOT EDIT THIS FILE DIRECTLY.
|
||||
|--------------------------------------------------------------------------
|
||||
| This file reads from your .env configuration file and should not
|
||||
| be modified directly.
|
||||
*/
|
||||
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DO NOT EDIT THIS FILE DIRECTLY.
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
return array(
|
||||
|
||||
'Global' => array(
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DO NOT EDIT THIS FILE DIRECTLY.
|
||||
|--------------------------------------------------------------------------
|
||||
| This file reads from your .env configuration file and should not
|
||||
| be modified directly.
|
||||
*/
|
||||
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,5 +1,15 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DO NOT EDIT THIS FILE DIRECTLY.
|
||||
|--------------------------------------------------------------------------
|
||||
| This file reads from your .env configuration file and should not
|
||||
| be modified directly.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DO NOT EDIT THIS FILE DIRECTLY.
|
||||
|--------------------------------------------------------------------------
|
||||
| This file reads from your .env configuration file and should not
|
||||
| be modified directly.
|
||||
*/
|
||||
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<?php
|
||||
return array (
|
||||
'app_version' => 'v4.1.14',
|
||||
'full_app_version' => 'v4.1.14 - build 3416-g14af95001',
|
||||
'build_version' => '3416',
|
||||
'full_app_version' => 'v4.1.14 - build 3446-g90bff709a',
|
||||
'build_version' => '3446',
|
||||
'prerelease_version' => '',
|
||||
'hash_version' => 'g14af95001',
|
||||
'full_hash' => 'v4.1.14-25-g14af95001',
|
||||
'hash_version' => 'g90bff709a',
|
||||
'full_hash' => 'v4.1.14-55-g90bff709a',
|
||||
'branch' => 'master',
|
||||
);
|
||||
|
|
|
@ -18,13 +18,15 @@ $factory->define(Statuslabel::class, function (Faker\Generator $faker) {
|
|||
$factory->state(Statuslabel::class, 'rtd', function (Faker\Generator $faker) {
|
||||
return [
|
||||
'notes' => $faker->sentence,
|
||||
'deployable' => 1
|
||||
'deployable' => 1,
|
||||
'default_label' => 1,
|
||||
];
|
||||
});
|
||||
$factory->state(Statuslabel::class, 'pending', function (Faker\Generator $faker) {
|
||||
return [
|
||||
'notes' => $faker->sentence,
|
||||
'pending' => 1,
|
||||
'default_label' => 0,
|
||||
];
|
||||
});
|
||||
|
||||
|
@ -32,29 +34,34 @@ $factory->state(Statuslabel::class, 'archived', function (Faker\Generator $faker
|
|||
return [
|
||||
'notes' => 'These assets are permanently undeployable',
|
||||
'archived' => 1,
|
||||
'default_label' => 0,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Statuslabel::class, 'out_for_diagnostics', function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => 'Out for Diagnostics',
|
||||
'default_label' => 0,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Statuslabel::class, 'out_for_repair', function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => 'Out for Repair',
|
||||
'default_label' => 0,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Statuslabel::class, 'broken', function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => 'Broken - Not Fixable',
|
||||
'default_label' => 0,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Statuslabel::class, 'lost', function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => 'Lost/Stolen',
|
||||
'default_label' => 0,
|
||||
];
|
||||
});
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddDefaultFlagOnStatuslabels extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('status_labels', function (Blueprint $table) {
|
||||
$table->boolean('default_label')->default(0);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('status_labels', function (Blueprint $table) {
|
||||
$table->dropColumn('default_label');
|
||||
});
|
||||
}
|
||||
}
|
|
@ -5,6 +5,8 @@ return array(
|
|||
'archived' => 'Archived',
|
||||
'create' => 'Create Status Label',
|
||||
'color' => 'Chart Color',
|
||||
'default_label' => 'Default Label',
|
||||
'default_label_help' => 'This is used to ensure your most commonly used status labels appear at the top of the select box when creating/editing assets.',
|
||||
'deployable' => 'Deployable',
|
||||
'info' => 'Status labels are used to describe the various states your assets could be in. They may be out for repair, lost/stolen, etc. You can create new status labels for deployable, pending and archived assets.',
|
||||
'name' => 'Status Name',
|
||||
|
|
|
@ -81,6 +81,7 @@
|
|||
'filastname_format' => 'First Initial Last Name (jsmith@example.com)',
|
||||
'firstname_lastname_format' => 'First Name Last Name (jane.smith@example.com)',
|
||||
'firstname_lastname_underscore_format' => 'First Name Last Name (jane_smith@example.com)',
|
||||
'lastnamefirstinitial_format' => 'Last Name First Initial (smithj@example.com)',
|
||||
'first' => 'First',
|
||||
'first_name' => 'First Name',
|
||||
'first_name_format' => 'First Name (jane@example.com)',
|
||||
|
|
|
@ -456,6 +456,7 @@ Form::macro('username_format', function ($name = "username_format", $selected =
|
|||
'firstname.lastname' => trans('general.firstname_lastname_format'),
|
||||
'firstname' => trans('general.first_name_format'),
|
||||
'filastname' => trans('general.filastname_format'),
|
||||
'lastnamefirstinitial' => trans('general.lastnamefirstinitial_format'),
|
||||
'firstname_lastname' => trans('general.firstname_lastname_underscore_format'),
|
||||
|
||||
);
|
||||
|
|
|
@ -524,8 +524,8 @@
|
|||
</a>
|
||||
|
||||
<ul class="treeview-menu">
|
||||
@can('view', \App\Models\Customfield::class)
|
||||
<li {!! (Request::is('custom_fields*') ? ' class="active"' : '') !!}>
|
||||
@can('view', \App\Models\CustomField::class)
|
||||
<li {!! (Request::is('fields*') ? ' class="active"' : '') !!}>
|
||||
<a href="{{ route('fields.index') }}">
|
||||
{{ trans('admin/custom_fields/general.custom_fields') }}
|
||||
</a>
|
||||
|
|
|
@ -53,6 +53,15 @@
|
|||
</label>
|
||||
</div>
|
||||
|
||||
<!-- Set as Default -->
|
||||
<div class="form-group{{ $errors->has('default_label') ? ' has-error' : '' }}">
|
||||
|
||||
<label class="col-md-offset-3" style="padding-left: 15px;">
|
||||
<input type="checkbox" value="1" name="default_label" id="default_label" class="minimal" {{ Input::old('default_label', $item->default_label) == '1' ? ' checked="checked"' : '' }}> {{ trans('admin/statuslabels/table.default_label') }}
|
||||
</label>
|
||||
<p class="col-md-offset-3 help-block"> {{ trans('admin/statuslabels/table.default_label_help') }}</p>
|
||||
</div>
|
||||
|
||||
@stop
|
||||
|
||||
@section('moar_scripts')
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
<th data-sortable="true" data-field="assets_count">{{ trans('general.assets') }}</th>
|
||||
<th data-sortable="true" data-field="color" data-formatter="colorSqFormatter">{{ trans('admin/statuslabels/table.color') }}</th>
|
||||
<th class="text-center" data-sortable="true" data-field="show_in_nav" data-formatter="trueFalseFormatter">{{ trans('admin/statuslabels/table.show_in_nav') }}</th>
|
||||
<th class="text-center" data-sortable="true" data-field="default_label" data-formatter="trueFalseFormatter">{{ trans('admin/statuslabels/table.default_label') }}</th>
|
||||
<th data-formatter="statuslabelsActionsFormatter" data-searchable="false" data-sortable="false" data-field="actions">{{ trans('table.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
|
|
@ -54,6 +54,14 @@ class UserTest extends BaseTest
|
|||
$this->assertEquals($expected_username, $user['username']);
|
||||
}
|
||||
|
||||
public function testLastNameFirstInitial()
|
||||
{
|
||||
$fullname = "Natalia Allanovna Romanova-O'Shostakova";
|
||||
$expected_username = 'allanovna-romanova-oshostakovan';
|
||||
$user = User::generateFormattedNameFromFullName('lastnamefirstinitial', $fullname);
|
||||
$this->assertEquals($expected_username, $user['username']);
|
||||
}
|
||||
|
||||
|
||||
public function testFirstInitialLastName()
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue