Skip to content

Commit

Permalink
Implement KKT role
Browse files Browse the repository at this point in the history
  • Loading branch information
imol-ai committed Apr 15, 2024
1 parent 66dc826 commit 7da3a89
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 5 deletions.
9 changes: 7 additions & 2 deletions app/Models/Role.php
Expand Up @@ -57,6 +57,7 @@ class Role extends Model
public const CULTURAL_LEADER = 'cultural-leader';
public const CULTURAL_REFERENT = 'cultural-referent';
public const CULTURAL_MEMBER = 'cultural-member';
public const KKT_HANDLER = 'kkt-handler';
public const COMMUNITY_LEADER = 'community-leader';
public const COMMUNITY_REFERENT = 'community-referent';
public const COMMUNITY_MEMBER = 'community-member';
Expand Down Expand Up @@ -96,7 +97,8 @@ class Role extends Model
self::STUDENT_COUNCIL_SECRETARY,
self::STUDENT_COUNCIL,
self::BOARD_OF_TRUSTEES_MEMBER,
self::ETHICS_COMMISSIONER
self::ETHICS_COMMISSIONER,
self::KKT_HANDLER,
];

// Module-related roles
Expand Down Expand Up @@ -124,7 +126,9 @@ class Role extends Model
self::STUDENT_COUNCIL_SECRETARY,
self::BOARD_OF_TRUSTEES_MEMBER,
self::ETHICS_COMMISSIONER,
self::ALUMNI
self::ALUMNI,
self::KKT_HANDLER,

];

protected $fillable = [
Expand Down Expand Up @@ -310,6 +314,7 @@ public function color(): string
self::BOARD_OF_TRUSTEES_MEMBER => 'deep-orange darken-1',
self::ETHICS_COMMISSIONER => 'green lighten-2',
self::ALUMNI => 'grey darken-1',
self::KKT_HANDLER => 'orange darken-3',
default => 'grey',
};
}
Expand Down
5 changes: 2 additions & 3 deletions app/Policies/CheckoutPolicy.php
Expand Up @@ -44,11 +44,10 @@ public function addKKTNetreg(User $user): bool
{
return $user->hasRole([
Role::SYS_ADMIN,
Role::KKT_HANDLER,
Role::STUDENT_COUNCIL => [
Role::ECONOMIC_VICE_PRESIDENT,
Role::CULTURAL_LEADER,
Role::CULTURAL_MEMBER
]
],
]);
}

Expand Down
9 changes: 9 additions & 0 deletions app/Policies/UserPolicy.php
Expand Up @@ -265,12 +265,17 @@ public function updateAnyPermission(User $user, User $target, Role $role = null)
return $user->hasRole([Role::STUDENT_COUNCIL_SECRETARY, Role::STUDENT_COUNCIL => Role::STUDENT_COUNCIL_LEADERS]);
}

if ($role->name == Role::KKT_HANDLER) {
return $user->hasRole([Role::STUDENT_COUNCIL_SECRETARY, Role::STUDENT_COUNCIL => Role::ECONOMIC_VICE_PRESIDENT]);
}

if ($role->name == Role::STUDENT_COUNCIL) {
return $user->hasRole([
Role::STUDENT_COUNCIL => array_merge(Role::STUDENT_COUNCIL_LEADERS, Role::COMMITTEE_LEADERS),
Role::STUDENT_COUNCIL_SECRETARY
]);
}

return false;
}

Expand Down Expand Up @@ -299,6 +304,10 @@ public function updatePermission(User $user, User $target, Role $role, Workshop|
return $user->hasRole([Role::STUDENT_COUNCIL_SECRETARY, Role::STUDENT_COUNCIL => Role::STUDENT_COUNCIL_LEADERS]);
}

if ($role->name == Role::KKT_HANDLER) {
return $user->hasRole([Role::STUDENT_COUNCIL_SECRETARY, Role::STUDENT_COUNCIL => Role::ECONOMIC_VICE_PRESIDENT]);
}

if ($role->name == Role::WORKSHOP_LEADER) {
return $user->hasRole([Role::SECRETARY, Role::DIRECTOR]);
}
Expand Down
34 changes: 34 additions & 0 deletions database/migrations/2024_04_15_171918_add_kkt_role.php
@@ -0,0 +1,34 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (DB::table('roles')->where('name', 'kkt-handler')->doesntExist()) {
DB::table('roles')->insert([
'name' => 'kkt-handler',
'has_workshops' => false,
'has_objects' => false
]);
}
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
DB::table('roles')->where('name', 'kkt-handler')->delete();
}
};
1 change: 1 addition & 0 deletions resources/lang/en/role.php
Expand Up @@ -31,6 +31,7 @@
'hu' => 'Hungarian',
'internet-user' => 'Internet user',
'it' => 'Italian',
'kkt-handler' => 'Handler of Community & Culture Tax',
'la' => 'Latin',
'locale-admin' => 'Locale admin',
'other' => 'Other',
Expand Down
1 change: 1 addition & 0 deletions resources/lang/hu/role.php
Expand Up @@ -31,6 +31,7 @@
'hu' => 'Magyar',
'internet-user' => 'Internethasználó',
'it' => 'Olasz',
'kkt-handler' => 'KKT befizetőhely',
'la' => 'Latin',
'locale-admin' => 'Nyelvi adminisztrátor',
'other' => 'Egyéb',
Expand Down

0 comments on commit 7da3a89

Please sign in to comment.