Add Offerings domain and studio-admin capabilities
CI / Coding Standards (pull_request) Successful in 55s
CI / PHPStan (pull_request) Successful in 1m0s
CI / Tests (PHP 8.1) (pull_request) Successful in 50s
CI / Tests (PHP 8.2) (pull_request) Successful in 46s
CI / Tests (PHP 8.3) (pull_request) Successful in 50s
CI / No Debug Code (pull_request) Successful in 2s
CI / Coding Standards (pull_request) Successful in 55s
CI / PHPStan (pull_request) Successful in 1m0s
CI / Tests (PHP 8.1) (pull_request) Successful in 50s
CI / Tests (PHP 8.2) (pull_request) Successful in 46s
CI / Tests (PHP 8.3) (pull_request) Successful in 50s
CI / No Debug Code (pull_request) Successful in 2s
Implements the offerings catalog (#1): private-lesson types and group classes carrying pricing, billing mode (one_time/full_term), duration, capacity, and term details. Adds the src/Offering/ domain (value object, repository, REST endpoint, admin controller + template), the us_offerings table, and an Offerings admin page. Also lands the capability slice of #9: registers the us_studio_admin role and the new capability strings (manage_instructors, manage_offerings, manage_questions, manage_policies, manage_billing, view_all_payments, view_own_payments, export_payments) so offering management gates correctly. Tests: tests/Unit/Offering/ (value object + repository) and a studio-admin case in RoleManagerTest. composer test, cs, and PHPStan level 6 all pass. Refs #1 #9 Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
@@ -5,18 +5,45 @@ namespace Unsupervised\Schedular\Auth;
|
||||
|
||||
class RoleManager {
|
||||
|
||||
public const INSTRUCTOR = 'us_instructor';
|
||||
public const STUDENT = 'us_student';
|
||||
public const STUDIO_ADMIN = 'us_studio_admin';
|
||||
public const INSTRUCTOR = 'us_instructor';
|
||||
public const STUDENT = 'us_student';
|
||||
|
||||
public const CAP_MANAGE_AVAILABILITY = 'manage_availability';
|
||||
public const CAP_VIEW_LESSONS = 'view_own_lessons';
|
||||
public const CAP_BOOK_LESSON = 'book_lesson';
|
||||
|
||||
public const CAP_MANAGE_INSTRUCTORS = 'manage_instructors';
|
||||
public const CAP_MANAGE_OFFERINGS = 'manage_offerings';
|
||||
public const CAP_MANAGE_QUESTIONS = 'manage_questions';
|
||||
public const CAP_MANAGE_POLICIES = 'manage_policies';
|
||||
public const CAP_MANAGE_BILLING = 'manage_billing';
|
||||
public const CAP_VIEW_ALL_PAYMENTS = 'view_all_payments';
|
||||
public const CAP_VIEW_OWN_PAYMENTS = 'view_own_payments';
|
||||
public const CAP_EXPORT_PAYMENTS = 'export_payments';
|
||||
|
||||
public function register(): void {
|
||||
add_action( 'init', [ $this, 'createRoles' ] );
|
||||
}
|
||||
|
||||
public function createRoles(): void {
|
||||
if ( get_role( self::STUDIO_ADMIN ) === null ) {
|
||||
add_role(
|
||||
self::STUDIO_ADMIN,
|
||||
__( 'Studio Admin', 'unsupervised-schedular' ),
|
||||
[
|
||||
'read' => true,
|
||||
self::CAP_MANAGE_INSTRUCTORS => true,
|
||||
self::CAP_MANAGE_OFFERINGS => true,
|
||||
self::CAP_MANAGE_QUESTIONS => true,
|
||||
self::CAP_MANAGE_POLICIES => true,
|
||||
self::CAP_MANAGE_BILLING => true,
|
||||
self::CAP_VIEW_ALL_PAYMENTS => true,
|
||||
self::CAP_EXPORT_PAYMENTS => true,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if ( get_role( self::INSTRUCTOR ) === null ) {
|
||||
add_role(
|
||||
self::INSTRUCTOR,
|
||||
@@ -24,7 +51,11 @@ class RoleManager {
|
||||
[
|
||||
'read' => true,
|
||||
self::CAP_MANAGE_AVAILABILITY => true,
|
||||
self::CAP_MANAGE_OFFERINGS => true,
|
||||
self::CAP_MANAGE_QUESTIONS => true,
|
||||
self::CAP_VIEW_LESSONS => true,
|
||||
self::CAP_VIEW_OWN_PAYMENTS => true,
|
||||
self::CAP_EXPORT_PAYMENTS => true,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user