You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2021/05/11 21:11:19 UTC

[airavata-django-portal] 01/01: AIRAVATA-3462 Fix verification that user can still access preferred grp

This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch AIRAVATA-3462
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git

commit 0c30e76d8652b30f3ac0dfc1c52c3c2c99f62855
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Tue May 11 17:10:52 2021 -0400

    AIRAVATA-3462 Fix verification that user can still access preferred grp
---
 django_airavata/apps/api/helpers.py | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/django_airavata/apps/api/helpers.py b/django_airavata/apps/api/helpers.py
index 19a1077..1974d18 100644
--- a/django_airavata/apps/api/helpers.py
+++ b/django_airavata/apps/api/helpers.py
@@ -63,18 +63,19 @@ class WorkspacePreferencesHelper:
                     most_recent_project.projectID))
             prefs.most_recent_project_id = most_recent_project.projectID
             prefs.save()
+        group_resource_profiles = request.airavata_client.getGroupResourceList(
+            request.authz_token, settings.GATEWAY_ID)
+        group_resource_profile_ids = map(lambda g: g.groupResourceProfileId, group_resource_profiles)
         if (not prefs.most_recent_group_resource_profile_id or
-                not self._can_read(
-                    request,
-                    prefs.most_recent_group_resource_profile_id)):
-            first_grp = self._get_first_group_resource_profile(request)
-            if first_grp:
-                logger.warn(f"_check: updating "
-                            f"most_recent_group_resource_profile_id to "
-                            f"{first_grp.groupResourceProfileId}")
-                prefs.most_recent_group_resource_profile_id = \
-                    first_grp.groupResourceProfileId
-                prefs.save()
+                prefs.most_recent_group_resource_profile_id not in group_resource_profile_ids):
+            first_grp_id = (group_resource_profile_ids[0]
+                            if len(group_resource_profile_ids) > 0
+                            else None)
+            logger.warn(f"_check: updating "
+                        f"most_recent_group_resource_profile_id to "
+                        f"{first_grp_id}")
+            prefs.most_recent_group_resource_profile_id = first_grp_id
+            prefs.save()
 
     def _can_write(self, request, entity_id):
         return request.airavata_client.userHasAccess(