From c536e01e65f67977bf502b1910d606211110876f Mon Sep 17 00:00:00 2001 From: Zimovchik Date: Tue, 9 Jul 2024 11:37:34 +0300 Subject: [PATCH 1/7] Update button.py removed adding link field by default and added the needed condition --- services_backend/routes/button.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/services_backend/routes/button.py b/services_backend/routes/button.py index f8dd4b1..c0b663c 100644 --- a/services_backend/routes/button.py +++ b/services_backend/routes/button.py @@ -129,7 +129,6 @@ def get_buttons( "id": button.id, "icon": button.icon, "name": button.name, - "link": button.link, "order": button.order, "type": button.type, "view": view.value, @@ -138,7 +137,10 @@ def get_buttons( } if view == ButtonView.ACTIVE: to_add["scopes"] = list(scopes) + if user_scopes.issuperset(button.required_scopes): + to_add["link"] = button.link result["buttons"].append(to_add) + return result @@ -177,7 +179,6 @@ def get_button( "id": button.id, "icon": button.icon, "name": button.name, - "link": button.link, "order": button.order, "type": button.type, "view": view.value, @@ -186,6 +187,8 @@ def get_button( } if view == ButtonView.ACTIVE: result["scopes"] = list(scopes) + if user_scopes.issuperset(button.required_scopes): + result["link"] = button.link return result From 3c7d24ab5d59714a88e66b5e94401b3287c59d1a Mon Sep 17 00:00:00 2001 From: Zimovchik Date: Tue, 9 Jul 2024 11:46:06 +0300 Subject: [PATCH 2/7] Update button.py --- services_backend/routes/button.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services_backend/routes/button.py b/services_backend/routes/button.py index c0b663c..1660273 100644 --- a/services_backend/routes/button.py +++ b/services_backend/routes/button.py @@ -140,7 +140,7 @@ def get_buttons( if user_scopes.issuperset(button.required_scopes): to_add["link"] = button.link result["buttons"].append(to_add) - + return result From 6e9c0fc16cec7f01830dd480d30e81f1f0187c8b Mon Sep 17 00:00:00 2001 From: Zimovchik Date: Thu, 11 Jul 2024 10:42:06 +0300 Subject: [PATCH 3/7] new fix --- services_backend/routes/button.py | 11 +++++------ services_backend/routes/category.py | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/services_backend/routes/button.py b/services_backend/routes/button.py index 1660273..7c01331 100644 --- a/services_backend/routes/button.py +++ b/services_backend/routes/button.py @@ -131,14 +131,13 @@ def get_buttons( "name": button.name, "order": button.order, "type": button.type, + "link": button.link if user_scopes.issuperset(button.required_scopes) else None, "view": view.value, "required_scopes": button.required_scopes, "optional_scopes": button.optional_scopes, } if view == ButtonView.ACTIVE: to_add["scopes"] = list(scopes) - if user_scopes.issuperset(button.required_scopes): - to_add["link"] = button.link result["buttons"].append(to_add) return result @@ -181,14 +180,14 @@ def get_button( "name": button.name, "order": button.order, "type": button.type, + "link": button.link if user_scopes.issuperset(button.required_scopes) else None, "view": view.value, - "required_scopes": button.required_scopes, + "required_scopes": button. + required_scopes, "optional_scopes": button.optional_scopes, } if view == ButtonView.ACTIVE: result["scopes"] = list(scopes) - if user_scopes.issuperset(button.required_scopes): - result["link"] = button.link return result @@ -308,7 +307,7 @@ def get_service( "id": button.id, "icon": button.icon, "name": button.name, - "link": button.link, + "link": button.link if user_scopes.issuperset(button.required_scopes) else None, "order": button.order, "type": button.type, "view": view.value, diff --git a/services_backend/routes/category.py b/services_backend/routes/category.py index c924938..203b38a 100644 --- a/services_backend/routes/category.py +++ b/services_backend/routes/category.py @@ -119,7 +119,7 @@ def get_categories( "id": button.id, "icon": button.icon, "name": button.name, - "link": button.link, + "link": button.link if user_scopes.issuperset(button.required_scopes) else None, "order": button.order, "type": button.type, "view": view.value, From e0d5eb5e25338ae8535ec5ff5b15e6911522a543 Mon Sep 17 00:00:00 2001 From: Zimovchik Date: Thu, 11 Jul 2024 10:44:30 +0300 Subject: [PATCH 4/7] lint --- services_backend/routes/button.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/services_backend/routes/button.py b/services_backend/routes/button.py index 7c01331..bdc7838 100644 --- a/services_backend/routes/button.py +++ b/services_backend/routes/button.py @@ -182,8 +182,7 @@ def get_button( "type": button.type, "link": button.link if user_scopes.issuperset(button.required_scopes) else None, "view": view.value, - "required_scopes": button. - required_scopes, + "required_scopes": button.required_scopes, "optional_scopes": button.optional_scopes, } if view == ButtonView.ACTIVE: From 690a663c7289f5641559560200b883cae709b7c5 Mon Sep 17 00:00:00 2001 From: Zimovchik Date: Thu, 11 Jul 2024 12:56:50 +0300 Subject: [PATCH 5/7] add block check --- services_backend/routes/button.py | 8 +++++--- services_backend/routes/category.py | 6 +++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/services_backend/routes/button.py b/services_backend/routes/button.py index bdc7838..cc20fa5 100644 --- a/services_backend/routes/button.py +++ b/services_backend/routes/button.py @@ -131,7 +131,9 @@ def get_buttons( "name": button.name, "order": button.order, "type": button.type, - "link": button.link if user_scopes.issuperset(button.required_scopes) else None, + "link": ( + button.link if user_scopes.issuperset(button.required_scopes) and view == ButtonView.ACTIVE else None + ), "view": view.value, "required_scopes": button.required_scopes, "optional_scopes": button.optional_scopes, @@ -180,7 +182,7 @@ def get_button( "name": button.name, "order": button.order, "type": button.type, - "link": button.link if user_scopes.issuperset(button.required_scopes) else None, + "link": button.link if user_scopes.issuperset(button.required_scopes) and view == ButtonView.ACTIVE else None, "view": view.value, "required_scopes": button.required_scopes, "optional_scopes": button.optional_scopes, @@ -306,7 +308,7 @@ def get_service( "id": button.id, "icon": button.icon, "name": button.name, - "link": button.link if user_scopes.issuperset(button.required_scopes) else None, + "link": button.link if user_scopes.issuperset(button.required_scopes) and view == ButtonView.ACTIVE else None, "order": button.order, "type": button.type, "view": view.value, diff --git a/services_backend/routes/category.py b/services_backend/routes/category.py index 203b38a..7d75a9f 100644 --- a/services_backend/routes/category.py +++ b/services_backend/routes/category.py @@ -119,7 +119,11 @@ def get_categories( "id": button.id, "icon": button.icon, "name": button.name, - "link": button.link if user_scopes.issuperset(button.required_scopes) else None, + "link": ( + button.link + if user_scopes.issuperset(button.required_scopes) and view == ButtonView.ACTIVE + else None + ), "order": button.order, "type": button.type, "view": view.value, From a02a32bc9768facb81b0f0384216f4d24e023a21 Mon Sep 17 00:00:00 2001 From: Zimovchik Date: Thu, 11 Jul 2024 23:37:55 +0300 Subject: [PATCH 6/7] changing the way of checking required scopes --- services_backend/routes/button.py | 8 +++----- services_backend/routes/category.py | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/services_backend/routes/button.py b/services_backend/routes/button.py index cc20fa5..3468b28 100644 --- a/services_backend/routes/button.py +++ b/services_backend/routes/button.py @@ -131,9 +131,7 @@ def get_buttons( "name": button.name, "order": button.order, "type": button.type, - "link": ( - button.link if user_scopes.issuperset(button.required_scopes) and view == ButtonView.ACTIVE else None - ), + "link": button.link if view == ButtonView.ACTIVE else None, "view": view.value, "required_scopes": button.required_scopes, "optional_scopes": button.optional_scopes, @@ -182,7 +180,7 @@ def get_button( "name": button.name, "order": button.order, "type": button.type, - "link": button.link if user_scopes.issuperset(button.required_scopes) and view == ButtonView.ACTIVE else None, + "link": button.link if view == ButtonView.ACTIVE else None, "view": view.value, "required_scopes": button.required_scopes, "optional_scopes": button.optional_scopes, @@ -308,7 +306,7 @@ def get_service( "id": button.id, "icon": button.icon, "name": button.name, - "link": button.link if user_scopes.issuperset(button.required_scopes) and view == ButtonView.ACTIVE else None, + "link": button.link if view == ButtonView.ACTIVE else None, "order": button.order, "type": button.type, "view": view.value, diff --git a/services_backend/routes/category.py b/services_backend/routes/category.py index 7d75a9f..430d32a 100644 --- a/services_backend/routes/category.py +++ b/services_backend/routes/category.py @@ -121,7 +121,7 @@ def get_categories( "name": button.name, "link": ( button.link - if user_scopes.issuperset(button.required_scopes) and view == ButtonView.ACTIVE + if view == ButtonView.ACTIVE else None ), "order": button.order, From 8b518e6d0002b4f137031fa6297053c72786415e Mon Sep 17 00:00:00 2001 From: Zimovchik Date: Thu, 11 Jul 2024 23:40:14 +0300 Subject: [PATCH 7/7] linting --- services_backend/routes/category.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/services_backend/routes/category.py b/services_backend/routes/category.py index 430d32a..fb1cc84 100644 --- a/services_backend/routes/category.py +++ b/services_backend/routes/category.py @@ -119,11 +119,7 @@ def get_categories( "id": button.id, "icon": button.icon, "name": button.name, - "link": ( - button.link - if view == ButtonView.ACTIVE - else None - ), + "link": (button.link if view == ButtonView.ACTIVE else None), "order": button.order, "type": button.type, "view": view.value,