refactor no self signup to shift self signup
This commit is contained in:
parent
4cd7103121
commit
383f8ebde5
|
@ -24,7 +24,7 @@ class AngelTypeFactory extends Factory
|
|||
|
||||
'restricted' => $this->faker->boolean(),
|
||||
'requires_driver_license' => $this->faker->boolean(),
|
||||
'no_self_signup' => $this->faker->boolean(),
|
||||
'shift_self_signup' => $this->faker->boolean(),
|
||||
'show_on_dashboard' => $this->faker->boolean(),
|
||||
'hide_register' => $this->faker->boolean(),
|
||||
];
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Engelsystem\Migrations;
|
||||
|
||||
use Engelsystem\Database\Migration\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class AngeltypesRenameNoSelfSignupToShiftSelfSignup extends Migration
|
||||
{
|
||||
use Reference;
|
||||
|
||||
/**
|
||||
* Run the migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$this->schema->table('angel_types', function (Blueprint $table): void {
|
||||
$table->renameColumn('no_self_signup', 'shift_self_signup')->default(true);
|
||||
$connection = $this->schema->getConnection();
|
||||
$connection->table('angel_types')
|
||||
->update(['no_self_signup' => $connection->raw('NOT no_self_signup'),
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
$this->schema->table('angel_types', function (Blueprint $table): void {
|
||||
$table->renameColumn('shift_self_signup', 'no_self_signup');
|
||||
$connection = $this->schema->getConnection();
|
||||
$connection->table('angel_types')
|
||||
->update(['shift_self_signup' => $connection->raw('NOT shift_self_signup'),
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -118,7 +118,7 @@ function angeltype_edit_controller()
|
|||
}
|
||||
|
||||
$angeltype->restricted = $request->has('restricted');
|
||||
$angeltype->no_self_signup = $request->has('no_self_signup');
|
||||
$angeltype->shift_self_signup = $request->has('shift_self_signup');
|
||||
$angeltype->show_on_dashboard = $request->has('show_on_dashboard');
|
||||
$angeltype->hide_register = $request->has('hide_register');
|
||||
|
||||
|
@ -138,7 +138,7 @@ function angeltype_edit_controller()
|
|||
success('Angel type saved.');
|
||||
engelsystem_log(
|
||||
'Saved angeltype: ' . $angeltype->name . ($angeltype->restricted ? ', restricted' : '')
|
||||
. ($angeltype->no_self_signup ? ', no_self_signup' : '')
|
||||
. ($angeltype->shift_self_signup ? ', shift_self_signup' : '')
|
||||
. ($angeltype->requires_driver_license ? ', requires driver license' : '') . ', '
|
||||
. ($angeltype->requires_ifsg_certificate ? ', requires ifsg certificate' : '') . ', '
|
||||
. $angeltype->contact_name . ', '
|
||||
|
@ -318,7 +318,7 @@ function angeltypes_list_controller()
|
|||
}
|
||||
|
||||
$angeltype->is_restricted = $angeltype->restricted ? icon('mortarboard-fill') : '';
|
||||
$angeltype->no_self_signup_allowed = $angeltype->no_self_signup ? '' : icon('pencil-square');
|
||||
$angeltype->shift_self_signup_allowed = $angeltype->shift_self_signup ? icon('pencil-square') : '';
|
||||
|
||||
$angeltype->name = '<a href="'
|
||||
. page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype->id])
|
||||
|
|
|
@ -19,7 +19,7 @@ function NeededAngelTypes_by_shift($shiftId)
|
|||
`angel_types`.`id`,
|
||||
`angel_types`.`name`,
|
||||
`angel_types`.`restricted`,
|
||||
`angel_types`.`no_self_signup`
|
||||
`angel_types`.`shift_self_signup`
|
||||
FROM `needed_angel_types`
|
||||
JOIN `angel_types` ON `angel_types`.`id` = `needed_angel_types`.`angel_type_id`
|
||||
WHERE `shift_id` = ?
|
||||
|
|
|
@ -156,7 +156,7 @@ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
|||
`angel_types`.`id`,
|
||||
`angel_types`.`name`,
|
||||
`angel_types`.`restricted`,
|
||||
`angel_types`.`no_self_signup`
|
||||
`angel_types`.`shift_self_signup`
|
||||
FROM `shifts`
|
||||
JOIN `needed_angel_types` ON `needed_angel_types`.`shift_id`=`shifts`.`id`
|
||||
JOIN `angel_types` ON `angel_types`.`id`= `needed_angel_types`.`angel_type_id`
|
||||
|
@ -173,7 +173,7 @@ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
|||
`angel_types`.`id`,
|
||||
`angel_types`.`name`,
|
||||
`angel_types`.`restricted`,
|
||||
`angel_types`.`no_self_signup`
|
||||
`angel_types`.`shift_self_signup`
|
||||
FROM `shifts`
|
||||
JOIN `needed_angel_types` ON `needed_angel_types`.`room_id`=`shifts`.`room_id`
|
||||
JOIN `angel_types` ON `angel_types`.`id`= `needed_angel_types`.`angel_type_id`
|
||||
|
@ -209,7 +209,7 @@ function NeededAngeltype_by_Shift_and_Angeltype(Shift $shift, AngelType $angelty
|
|||
`angel_types`.`id`,
|
||||
`angel_types`.`name`,
|
||||
`angel_types`.`restricted`,
|
||||
`angel_types`.`no_self_signup`
|
||||
`angel_types`.`shift_self_signup`
|
||||
FROM `shifts`
|
||||
JOIN `needed_angel_types` ON `needed_angel_types`.`shift_id`=`shifts`.`id`
|
||||
JOIN `angel_types` ON `angel_types`.`id`= `needed_angel_types`.`angel_type_id`
|
||||
|
@ -226,7 +226,7 @@ function NeededAngeltype_by_Shift_and_Angeltype(Shift $shift, AngelType $angelty
|
|||
`angel_types`.`id`,
|
||||
`angel_types`.`name`,
|
||||
`angel_types`.`restricted`,
|
||||
`angel_types`.`no_self_signup`
|
||||
`angel_types`.`shift_self_signup`
|
||||
FROM `shifts`
|
||||
JOIN `needed_angel_types` ON `needed_angel_types`.`room_id`=`shifts`.`room_id`
|
||||
JOIN `angel_types` ON `angel_types`.`id`= `needed_angel_types`.`angel_type_id`
|
||||
|
@ -368,12 +368,12 @@ function Shift_signup_allowed_angel(
|
|||
|
||||
if (
|
||||
empty($user_angeltype)
|
||||
|| $angeltype->no_self_signup == 1
|
||||
|| ($angeltype->restricted == 1 && !isset($user_angeltype['confirm_user_id']))
|
||||
|| !$angeltype->shift_self_signup
|
||||
|| ($angeltype->restricted && !isset($user_angeltype['confirm_user_id']))
|
||||
) {
|
||||
// you cannot join if user is not of this angel type
|
||||
// you cannot join if angeltype has shift self signup disabled
|
||||
// you cannot join if you are not confirmed
|
||||
// you cannot join if angeltype has no self signup
|
||||
|
||||
return new ShiftSignupState(ShiftSignupStatus::ANGELTYPE, $free_entries);
|
||||
}
|
||||
|
|
|
@ -97,8 +97,14 @@ function AngelType_edit_view(AngelType $angeltype, bool $supporter_mode)
|
|||
__('Angel types which require introduction can only be used by an angel if enabled by a supporter (double opt-in).')
|
||||
),
|
||||
$supporter_mode
|
||||
? form_info(__('No Self Sign Up allowed'), $angeltype->no_self_signup ? __('Yes') : __('No'))
|
||||
: form_checkbox('no_self_signup', __('No Self Sign Up allowed'), $angeltype->no_self_signup),
|
||||
? form_info(__('shift.self_signup'), $angeltype->shift_self_signup ? __('Yes') : __('No'))
|
||||
: form_checkbox(
|
||||
'shift_self_signup',
|
||||
__('shift.self_signup') .
|
||||
' <span class="bi bi-info-circle-fill text-info" data-bs-toggle="tooltip" title="' .
|
||||
__('angeltypes.shift.self_signup.info') . '"></span>',
|
||||
$angeltype->shift_self_signup
|
||||
),
|
||||
$supporter_mode ?
|
||||
form_info(
|
||||
__('Requires driver license'),
|
||||
|
@ -571,11 +577,11 @@ function AngelTypes_list_view($angeltypes, bool $admin_angeltypes)
|
|||
button(url('/angeltypes/about'), __('angeltypes.about')),
|
||||
]),
|
||||
table([
|
||||
'name' => __('Name'),
|
||||
'is_restricted' => icon('mortarboard-fill') . __('Requires introduction'),
|
||||
'no_self_signup_allowed' => icon('pencil-square') . __('Self Sign Up Allowed'),
|
||||
'membership' => __('Membership'),
|
||||
'actions' => '',
|
||||
'name' => __('Name'),
|
||||
'is_restricted' => icon('mortarboard-fill') . __('Requires introduction'),
|
||||
'shift_self_signup_allowed' => icon('pencil-square') . __('shift.self_signup.allowed'),
|
||||
'membership' => __('Membership'),
|
||||
'actions' => '',
|
||||
], $angeltypes),
|
||||
], true);
|
||||
}
|
||||
|
|
|
@ -1303,8 +1303,18 @@ msgstr ""
|
|||
"Engeltypen, welche eine Einführung benötigen, müssen von einem Supporter freigeschaltet werden "
|
||||
"(double-opt-in)."
|
||||
|
||||
msgid "No Self Sign Up allowed"
|
||||
msgstr "Kein Selbst-Eintragen erlaubt"
|
||||
msgid "shift.self_signup"
|
||||
msgstr "Schichten selbst eintragen"
|
||||
|
||||
msgid "shift.self_signup.allowed"
|
||||
msgstr "Schichten selbst eintragen erlaubt"
|
||||
|
||||
msgid "angeltypes.shift.self_signup.info"
|
||||
msgstr "Engeltypen, welche Schichten selbst eintragen erlaubt haben, "
|
||||
"erlauben Engeln sich selbst in ihre Schichten einzutragen, "
|
||||
"ist Schichten selbst eintragen nicht erlaubt können nur Supporter "
|
||||
"oder Admins Engel in die Schichten des Engeltyps eintragen."
|
||||
|
||||
|
||||
msgid "Requires driver license"
|
||||
msgstr "Benötigt Führerschein"
|
||||
|
|
|
@ -531,6 +531,16 @@ msgstr "DECT"
|
|||
msgid "angeltypes.email"
|
||||
msgstr "E-Mail"
|
||||
|
||||
msgid "angeltypes.shift.self_signup.info"
|
||||
msgstr "Angel types which have shift self signup enabled allow angels to self sign up for there shifts, "
|
||||
"if shift self signup is disabled only supporters and admins can sign angels into shifts of these angel types."
|
||||
|
||||
msgid "shift.self_signup"
|
||||
msgstr "Shift self signup"
|
||||
|
||||
msgid "shift.self_signup.allowed"
|
||||
msgstr "Shift self signup allowed"
|
||||
|
||||
msgid "registration.register"
|
||||
msgstr "Register"
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ use Illuminate\Database\Query\Builder as QueryBuilder;
|
|||
* @property boolean $restricted # If users need an introduction
|
||||
* @property boolean $requires_driver_license # If users must have a driver license
|
||||
* @property boolean $requires_ifsg_certificate # If users must have a ifsg certificate
|
||||
* @property boolean $no_self_signup # Users can sign up for shifts
|
||||
* @property boolean $shift_self_signup # Users can sign up for shifts
|
||||
* @property boolean $show_on_dashboard # Show on public dashboard
|
||||
* @property boolean $hide_register # Hide from registration page
|
||||
*
|
||||
|
@ -49,7 +49,21 @@ class AngelType extends BaseModel
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
/** @var array<string> */
|
||||
/** @var array Default attributes */
|
||||
protected $attributes = [ // phpcs:ignore
|
||||
'restricted' => false,
|
||||
'requires_driver_license' => false,
|
||||
'requires_ifsg_certificate' => false,
|
||||
'shift_self_signup' => true,
|
||||
'show_on_dashboard' => false,
|
||||
'hide_register' => false,
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
protected $fillable = [ // phpcs:ignore
|
||||
'name',
|
||||
'description',
|
||||
|
@ -61,7 +75,7 @@ class AngelType extends BaseModel
|
|||
'restricted',
|
||||
'requires_driver_license',
|
||||
'requires_ifsg_certificate',
|
||||
'no_self_signup',
|
||||
'shift_self_signup',
|
||||
'show_on_dashboard',
|
||||
'hide_register',
|
||||
];
|
||||
|
@ -71,7 +85,7 @@ class AngelType extends BaseModel
|
|||
'restricted' => 'boolean',
|
||||
'requires_driver_license' => 'boolean',
|
||||
'requires_ifsg_certificate' => 'boolean',
|
||||
'no_self_signup' => 'boolean',
|
||||
'shift_self_signup' => 'boolean',
|
||||
'show_on_dashboard' => 'boolean',
|
||||
'hide_register' => 'boolean',
|
||||
];
|
||||
|
|
Loading…
Reference in New Issue