-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Zeva 343:Display "New User" button and make user list clickable only …
…if user is admin inside Vehicle supplier/users tab (#437) * ZEVA-343: Display "New User" button and make user list clickbale only if user is admin inside Vehicle supplier/users tab. * Add permission "VIEW_USERS" for Engineer/Analyst role. * Rename fixture to avoid conflict
- Loading branch information
1 parent
daa52c0
commit 635c833
Showing
6 changed files
with
73 additions
and
15 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
backend/api/fixtures/operational/0016_update_roles_permissions.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from django.db import transaction | ||
|
||
from api.management.data_script import OperationalDataScript | ||
from api.models.permission import Permission | ||
from api.models.role import Role | ||
from api.models.role_permission import RolePermission | ||
from api.authorities import REQUIRED_AUTHORITIES | ||
|
||
|
||
class UpdateRolesPermissions(OperationalDataScript): | ||
""" | ||
Adds the Roles and Permissions | ||
""" | ||
is_revertable = False | ||
comment = 'Updates the permissions for the roles so that they make more ' \ | ||
'sense with application.' | ||
|
||
def check_run_preconditions(self): | ||
return True | ||
|
||
def update_analyst(self): | ||
|
||
role = Role.objects.get( | ||
role_code="Engineer/Analyst" | ||
) | ||
|
||
permissions_to_be_added = [ | ||
'VIEW_USERS', | ||
] | ||
|
||
for permission_code in permissions_to_be_added: | ||
permission = Permission.objects.get(permission_code=permission_code) | ||
RolePermission.objects.get_or_create( | ||
permission=permission, | ||
role=role | ||
) | ||
|
||
@transaction.atomic | ||
def run(self): | ||
self.update_analyst() | ||
|
||
print('Updated Permissions') | ||
|
||
|
||
script_class = UpdateRolesPermissions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters