feat(api): If user is organization manager of any org, show organization within navigation
ref: #425 #426
This commit is contained in:
@ -11,6 +11,8 @@ from rest_framework.utils.field_mapping import ClassLookupDict
|
||||
|
||||
from rest_framework_json_api.utils import get_related_resource_type
|
||||
|
||||
from access.models import Organization
|
||||
|
||||
from app.serializers.user import User, UserBaseSerializer
|
||||
|
||||
from core import fields as centurion_field
|
||||
@ -450,6 +452,14 @@ class ReactUIMetadata(OverRideJSONAPIMetadata):
|
||||
'settings.view_appsettings',
|
||||
]
|
||||
|
||||
|
||||
# user = view.request.user
|
||||
|
||||
user_orgainzations = Organization.objects.filter(
|
||||
manager = user
|
||||
)
|
||||
|
||||
|
||||
for app, entry in self._nav.items():
|
||||
|
||||
new_menu_entry: dict = {}
|
||||
@ -494,6 +504,17 @@ class ReactUIMetadata(OverRideJSONAPIMetadata):
|
||||
new_pages += [ page ]
|
||||
|
||||
|
||||
if(
|
||||
app == 'access'
|
||||
and permission == 'view_organization'
|
||||
and len(user_orgainzations) > 0
|
||||
):
|
||||
|
||||
if page not in new_pages:
|
||||
|
||||
new_pages += [ page ]
|
||||
|
||||
|
||||
if len(new_pages) > 0:
|
||||
|
||||
new_menu_entry = entry.copy()
|
||||
|
Reference in New Issue
Block a user