You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ma...@apache.org on 2024/04/02 05:01:58 UTC

(superset) branch avatar_url updated (37b491e8bf -> 65f146168c)

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

maximebeauchemin pushed a change to branch avatar_url
in repository https://gitbox.apache.org/repos/asf/superset.git


    from 37b491e8bf feat: Slack Avatar integration
     new f43b92c884 minor tweaks
     new ce49a8aaa9 improve docs
     new 65f146168c fix test

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../src/components/FacePile/index.tsx              |  1 -
 superset/models/user.py                            | 21 ----------------
 superset/security/manager.py                       |  1 -
 superset/utils/slack.py                            | 17 +++++++++++++
 superset/views/users/api.py                        | 28 +++++++---------------
 tests/unit_tests/notifications/slack_tests.py      |  3 ++-
 6 files changed, 28 insertions(+), 43 deletions(-)
 delete mode 100644 superset/models/user.py


(superset) 03/03: fix test

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to branch avatar_url
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 65f146168c072693e8acde9b157696e1273c8501
Author: Maxime Beauchemin <ma...@gmail.com>
AuthorDate: Mon Apr 1 22:01:44 2024 -0700

    fix test
---
 tests/unit_tests/notifications/slack_tests.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/unit_tests/notifications/slack_tests.py b/tests/unit_tests/notifications/slack_tests.py
index 7e6cc3afc1..e423527df8 100644
--- a/tests/unit_tests/notifications/slack_tests.py
+++ b/tests/unit_tests/notifications/slack_tests.py
@@ -31,7 +31,8 @@ def test_send_slack(
     # requires app context
     from superset.reports.models import ReportRecipients, ReportRecipientType
     from superset.reports.notifications.base import NotificationContent
-    from superset.reports.notifications.slack import SlackNotification, WebClient
+    from superset.reports.notifications.slack import SlackNotification
+    from superset.utils.slack import WebClient
 
     execution_id = uuid.uuid4()
     flask_global_mock.logs_context = {"execution_id": execution_id}


(superset) 01/03: minor tweaks

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to branch avatar_url
in repository https://gitbox.apache.org/repos/asf/superset.git

commit f43b92c884ebdd925825f2052a7e6f527cc49b24
Author: Maxime Beauchemin <ma...@gmail.com>
AuthorDate: Mon Apr 1 21:52:43 2024 -0700

    minor tweaks
---
 superset-frontend/src/components/FacePile/index.tsx |  1 -
 superset/models/user.py                             | 21 ---------------------
 superset/security/manager.py                        |  1 -
 superset/utils/slack.py                             | 17 +++++++++++++++++
 superset/views/users/api.py                         |  4 +---
 5 files changed, 18 insertions(+), 26 deletions(-)

diff --git a/superset-frontend/src/components/FacePile/index.tsx b/superset-frontend/src/components/FacePile/index.tsx
index 77795113e3..27dee0d348 100644
--- a/superset-frontend/src/components/FacePile/index.tsx
+++ b/superset-frontend/src/components/FacePile/index.tsx
@@ -76,7 +76,6 @@ export default function FacePile({ users, maxCount = 4 }: FacePileProps) {
             </StyledAvatar>
           </Tooltip>
         );
-        return <img src={avatarUrl} />;
       })}
     </StyledGroup>
   );
diff --git a/superset/models/user.py b/superset/models/user.py
deleted file mode 100644
index 0ea5d1a332..0000000000
--- a/superset/models/user.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-from flask_appbuilder.security.sqla.models import User as FABUser
-
-
-class User(FABUser):
-    pass
diff --git a/superset/security/manager.py b/superset/security/manager.py
index 4ac773bb77..e5a32e97a7 100644
--- a/superset/security/manager.py
+++ b/superset/security/manager.py
@@ -200,7 +200,6 @@ def query_context_modified(query_context: "QueryContext") -> bool:
 class SupersetSecurityManager(  # pylint: disable=too-many-public-methods
     SecurityManager
 ):
-    user_model = User
     userstatschartview = None
     READ_ONLY_MODEL_VIEWS = {"Database", "DynamicPlugin"}
 
diff --git a/superset/utils/slack.py b/superset/utils/slack.py
index bf07653a40..93eefe4b87 100644
--- a/superset/utils/slack.py
+++ b/superset/utils/slack.py
@@ -1,3 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
 from flask import current_app
 from slack_sdk import WebClient
 
diff --git a/superset/views/users/api.py b/superset/views/users/api.py
index f26d78757c..d3aa29d595 100644
--- a/superset/views/users/api.py
+++ b/superset/views/users/api.py
@@ -154,9 +154,7 @@ class UserRestApi(BaseSupersetApi):
                     )
 
                     # Saving the avatar url to the database
-                    user_attrs = UserAttribute()
-                    user_attrs.user_id = user_id
-                    user_attrs.avatar_url = avatar_url
+                    user_attrs = UserAttribute(user_id=user_id, avatar_url=avatar_url)
                     db.session.add(user_attrs)
                     db.session.commit()
             elif user_attrs:


(superset) 02/03: improve docs

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to branch avatar_url
in repository https://gitbox.apache.org/repos/asf/superset.git

commit ce49a8aaa95b7f3e9ec35b1dc39111337a65a39e
Author: Maxime Beauchemin <ma...@gmail.com>
AuthorDate: Mon Apr 1 21:57:57 2024 -0700

    improve docs
---
 superset/views/users/api.py | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/superset/views/users/api.py b/superset/views/users/api.py
index d3aa29d595..2781769b11 100644
--- a/superset/views/users/api.py
+++ b/superset/views/users/api.py
@@ -109,25 +109,20 @@ class UserRestApi(BaseSupersetApi):
     @expose("/<user_id>/avatar.png", methods=("GET",))
     @safe
     def avatar(self, user_id: str) -> Response:
-        """Get the user roles corresponding to the agent making the request.
+        """Get a redirect to the avatar's URL for the user with the given ID.
         ---
         get:
-          summary: Get the user roles
+          summary: Get the user avatar
           description: >-
-            Gets the user roles corresponding to the agent making the request,
-            or returns a 401 error if the user is unauthenticated.
+            Gets the avatar URL for the user with the given ID, or returns a 401 error
+            if the user is unauthenticated.
           responses:
-            200:
-              description: The current user
-              content:
-                application/json:
-                  schema:
-                    type: object
-                    properties:
-                      result:
-                        $ref: '#/components/schemas/UserResponseSchema'
+            301:
+              description: A redirect to the user's avatar URL
             401:
               $ref: '#/components/responses/401'
+            404:
+              $ref: '#/components/responses/404'
         """
         try:
             avatar_url = None
@@ -167,6 +162,3 @@ class UserRestApi(BaseSupersetApi):
 
         except NoAuthorizationError:
             return self.response_401()
-        return self.response(
-            200, result=response.data.get("user").get("profile").get("image_192")
-        )