Add explicit TOC accepted checkbox #244

This commit is contained in:
Nabeel Shahzad
2018-09-20 11:14:18 -05:00
parent fbcaa382f4
commit ab5480fdc9
6 changed files with 65 additions and 4 deletions

View File

@@ -32,6 +32,7 @@ class CreateUsersTable extends Migration
$table->string('timezone', 64)->nullable();
$table->unsignedTinyInteger('status')->nullable()->default(0);
$table->unsignedTinyInteger('state')->nullable()->default(0);
$table->boolean('toc_accepted')->nullable();
$table->boolean('opt_in')->nullable();
$table->boolean('active')->nullable();
$table->ipAddress('last_ip')->nullable();

View File

@@ -25,6 +25,8 @@ users:
flight_time: 0
timezone: America/Chicago
state: 1
opt_in: 1
toc_accepted: 1
created_at: now
updated_at: now
- id: 2
@@ -41,6 +43,8 @@ users:
created_at: now
updated_at: now
state: 0
opt_in: 1
toc_accepted: 1
- id: 3
name: Raymond Pearson
email: raymond.pearson56@example.com
@@ -55,6 +59,8 @@ users:
created_at: now
updated_at: now
state: 1
opt_in: 0
toc_accepted: 1
role_user:
- user_id: 1

View File

@@ -86,6 +86,7 @@ class RegisterController extends Controller
'airline_id' => 'required',
'home_airport_id' => 'required',
'password' => 'required|min:5|confirmed',
'toc_accepted' => 'accepted',
];
if (config('captcha.enabled')) {
@@ -117,7 +118,7 @@ class RegisterController extends Controller
// Convert transfer hours into minutes
if (isset($opts['transfer_time'])) {
$opts['transfer_time'] = $opts['transfer_time'] * 60;
$opts['transfer_time'] *= 60;
}
$user = User::create($opts);
@@ -148,6 +149,7 @@ class RegisterController extends Controller
'timezone' => 'required',
'country' => 'required',
'transfer_time' => 'integer|min:0',
'toc_accepted' => 'accepted',
];
if (config('captcha.enabled')) {

View File

@@ -62,6 +62,7 @@ class User extends Authenticatable
'timezone',
'state',
'status',
'toc_accepted',
'opt_in',
'created_at',
'updated_at',
@@ -83,6 +84,7 @@ class User extends Authenticatable
'balance' => 'double',
'state' => 'integer',
'status' => 'integer',
'toc_accepted' => 'boolean',
'opt_in' => 'boolean',
];

View File

@@ -111,6 +111,10 @@
<td>Last Login</td>
<td>{{ show_datetime($user->updated_at) }}</td>
</tr>
<tr>
<td>@lang('toc.title')</td>
<td>{{ $user->toc_accepted ? __('common.yes') : __('common.no') }}</td>
</tr>
<tr>
<td>@lang('profile.opt-in')</td>
<td>{{ $user->opt_in ? __('common.yes') : __('common.no') }}</td>

View File

@@ -95,11 +95,45 @@
@endif
@endif
@include('auth.toc')
<div>
@include('auth.toc')
<br />
</div>
<table>
<tr>
<td style="vertical-align: top; padding: 5px 10px 0 0">
<div class="input-group form-group-no-border">
{{ Form::hidden('toc_accepted', 0, false) }}
{{ Form::checkbox('toc_accepted', 1, null, ['id' => 'toc_accepted']) }}
</div>
</td>
<td style="vertical-align: top;">
<label for="toc_accepted" class="control-label">@lang('auth.tocaccept')</label>
@if ($errors->has('toc_accepted'))
<p class="text-danger">{{ $errors->first('toc_accepted') }}</p>
@endif
</td>
</tr>
<tr>
<td>
<div class="input-group form-group-no-border">
{{ Form::hidden('opt_in', 0, false) }}
{{ Form::checkbox('opt_in', 1, null) }}
</div>
</td>
<td>
<label for="opt_in" class="control-label">@lang('profile.opt-in-descrip')</label>
</td>
</tr>
</table>
<div style="width: 100%; text-align: right; padding-top: 20px;">
@lang('auth.tocaccept')<br /><br />
{{ Form::submit(__('auth.register'), ['class' => 'btn btn-primary']) }}
{{ Form::submit(__('auth.register'), [
'id' => 'register_button',
'class' => 'btn btn-primary',
'disabled' => true,
]) }}
</div>
</div>
@@ -112,4 +146,16 @@
@section('scripts')
{!! NoCaptcha::renderJs(config('app.locale')) !!}
<script>
$('#toc_accepted').click(function () {
if ($(this).is(':checked')) {
console.log('toc accepted');
$('#register_button').removeAttr('disabled');
} else {
console.log('toc not accepted');
$('#register_button').attr('disabled', 'true');
}
});
</script>
@endsection