You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by di...@apache.org on 2023/05/15 13:55:45 UTC
[superset] branch chore/rm-username-response created (now 61592dcda6)
This is an automated email from the ASF dual-hosted git repository.
diegopucci pushed a change to branch chore/rm-username-response
in repository https://gitbox.apache.org/repos/asf/superset.git
at 61592dcda6 Remove username
This branch includes the following new commits:
new 61592dcda6 Remove username
The 1 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.
[superset] 01/01: Remove username
Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
diegopucci pushed a commit to branch chore/rm-username-response
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 61592dcda6bb546d49f014e6229a8858c3b72b65
Author: geido <di...@gmail.com>
AuthorDate: Mon May 15 16:55:22 2023 +0300
Remove username
---
superset/charts/api.py | 2 --
superset/connectors/sqla/models.py | 4 ++--
superset/dashboards/api.py | 3 ---
superset/dashboards/schemas.py | 4 ++--
superset/datasets/api.py | 4 +---
superset/models/dashboard.py | 3 ++-
superset/models/filter_set.py | 3 ++-
superset/models/slice.py | 3 +++
superset/queries/api.py | 1 -
superset/queries/schemas.py | 2 +-
superset/tags/schemas.py | 2 +-
11 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/superset/charts/api.py b/superset/charts/api.py
index 3235d3b000..6a4bf04aa1 100644
--- a/superset/charts/api.py
+++ b/superset/charts/api.py
@@ -134,7 +134,6 @@ class ChartRestApi(BaseSupersetModelRestApi):
"owners.first_name",
"owners.id",
"owners.last_name",
- "owners.username",
"dashboards.id",
"dashboards.dashboard_title",
"params",
@@ -183,7 +182,6 @@ class ChartRestApi(BaseSupersetModelRestApi):
"owners.first_name",
"owners.id",
"owners.last_name",
- "owners.username",
"dashboards.id",
"dashboards.dashboard_title",
"params",
diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py
index 22d546424e..7be02bf242 100644
--- a/superset/connectors/sqla/models.py
+++ b/superset/connectors/sqla/models.py
@@ -43,7 +43,7 @@ import numpy as np
import pandas as pd
import sqlalchemy as sa
import sqlparse
-from flask import escape, Markup
+from flask import current_app, escape, Markup
from flask_appbuilder import Model
from flask_babel import lazy_gettext as _
from jinja2.exceptions import TemplateError
@@ -650,7 +650,7 @@ class SqlaTable(
@property
def changed_by_url(self) -> str:
- if not self.changed_by:
+ if not self.changed_by or not current_app.config["ENABLE_BROAD_ACTIVITY_ACCESS"]:
return ""
return f"/superset/profile/{self.changed_by.username}"
diff --git a/superset/dashboards/api.py b/superset/dashboards/api.py
index cd481c2411..be248f7877 100644
--- a/superset/dashboards/api.py
+++ b/superset/dashboards/api.py
@@ -172,7 +172,6 @@ class DashboardRestApi(BaseSupersetModelRestApi):
"certification_details",
"changed_by.first_name",
"changed_by.last_name",
- "changed_by.username",
"changed_by.id",
"changed_by_name",
"changed_by_url",
@@ -184,10 +183,8 @@ class DashboardRestApi(BaseSupersetModelRestApi):
"created_by.last_name",
"dashboard_title",
"owners.id",
- "owners.username",
"owners.first_name",
"owners.last_name",
- "owners.email",
"roles.id",
"roles.name",
"is_managed_externally",
diff --git a/superset/dashboards/schemas.py b/superset/dashboards/schemas.py
index 156a3ac1f9..0965adefc4 100644
--- a/superset/dashboards/schemas.py
+++ b/superset/dashboards/schemas.py
@@ -190,10 +190,10 @@ class DashboardGetResponseSchema(Schema):
)
changed_by_name = fields.String()
changed_by_url = fields.String()
- changed_by = fields.Nested(UserSchema)
+ changed_by = fields.Nested(UserSchema(exclude=(["username"])))
changed_on = fields.DateTime()
charts = fields.List(fields.String(metadata={"description": charts_description}))
- owners = fields.List(fields.Nested(UserSchema))
+ owners = fields.List(fields.Nested(UserSchema(exclude=(["username"]))))
roles = fields.List(fields.Nested(RolesSchema))
tags = fields.Nested(TagSchema, many=True)
changed_on_humanized = fields.String(data_key="changed_on_delta_humanized")
diff --git a/superset/datasets/api.py b/superset/datasets/api.py
index c51be66f8f..d52e622793 100644
--- a/superset/datasets/api.py
+++ b/superset/datasets/api.py
@@ -103,7 +103,7 @@ class DatasetRestApi(BaseSupersetModelRestApi):
"changed_by_name",
"changed_by_url",
"changed_by.first_name",
- "changed_by.username",
+ "changed_by.last_name",
"changed_on_utc",
"changed_on_delta_humanized",
"default_endpoint",
@@ -113,7 +113,6 @@ class DatasetRestApi(BaseSupersetModelRestApi):
"extra",
"kind",
"owners.id",
- "owners.username",
"owners.first_name",
"owners.last_name",
"schema",
@@ -146,7 +145,6 @@ class DatasetRestApi(BaseSupersetModelRestApi):
"template_params",
"select_star",
"owners.id",
- "owners.username",
"owners.first_name",
"owners.last_name",
"columns.advanced_data_type",
diff --git a/superset/models/dashboard.py b/superset/models/dashboard.py
index 9292e1acd1..428a3def83 100644
--- a/superset/models/dashboard.py
+++ b/superset/models/dashboard.py
@@ -24,6 +24,7 @@ from functools import partial
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Type, Union
import sqlalchemy as sqla
+from flask import current_app
from flask_appbuilder import Model
from flask_appbuilder.models.decorators import renders
from flask_appbuilder.security.sqla.models import User
@@ -272,7 +273,7 @@ class Dashboard(Model, AuditMixinNullable, ImportExportMixin):
@property
def changed_by_url(self) -> str:
- if not self.changed_by:
+ if not self.changed_by or not current_app.config["ENABLE_BROAD_ACTIVITY_ACCESS"]:
return ""
return f"/superset/profile/{self.changed_by.username}"
diff --git a/superset/models/filter_set.py b/superset/models/filter_set.py
index 4bbef26490..df54f61692 100644
--- a/superset/models/filter_set.py
+++ b/superset/models/filter_set.py
@@ -20,6 +20,7 @@ import json
import logging
from typing import Any, Dict
+from flask import current_app
from flask_appbuilder import Model
from sqlalchemy import Column, ForeignKey, Integer, MetaData, String, Text
from sqlalchemy.orm import relationship
@@ -67,7 +68,7 @@ class FilterSet(Model, AuditMixinNullable):
@property
def changed_by_url(self) -> str:
- if not self.changed_by:
+ if not self.changed_by or not current_app.config["ENABLE_BROAD_ACTIVITY_ACCESS"]:
return ""
return f"/superset/profile/{self.changed_by.username}"
diff --git a/superset/models/slice.py b/superset/models/slice.py
index cc975d2635..1de45bbde3 100644
--- a/superset/models/slice.py
+++ b/superset/models/slice.py
@@ -22,6 +22,7 @@ from typing import Any, Dict, Optional, Type, TYPE_CHECKING
from urllib import parse
import sqlalchemy as sqla
+from flask import current_app
from flask_appbuilder import Model
from flask_appbuilder.models.decorators import renders
from markupsafe import escape, Markup
@@ -339,6 +340,8 @@ class Slice( # pylint: disable=too-many-public-methods
@property
def changed_by_url(self) -> str:
+ if not self.changed_by or not current_app.config["ENABLE_BROAD_ACTIVITY_ACCESS"]:
+ return ""
return f"/superset/profile/{self.changed_by.username}" # type: ignore
@property
diff --git a/superset/queries/api.py b/superset/queries/api.py
index a88b4b5ce8..bc60742024 100644
--- a/superset/queries/api.py
+++ b/superset/queries/api.py
@@ -82,7 +82,6 @@ class QueryRestApi(BaseSupersetModelRestApi):
"user.first_name",
"user.id",
"user.last_name",
- "user.username",
"start_time",
"end_time",
"tmp_table_name",
diff --git a/superset/queries/schemas.py b/superset/queries/schemas.py
index c29c1c03b6..b139784c5b 100644
--- a/superset/queries/schemas.py
+++ b/superset/queries/schemas.py
@@ -65,7 +65,7 @@ class QuerySchema(Schema):
tab_name = fields.String()
tmp_table_name = fields.String()
tracking_url = fields.String()
- user = fields.Nested(UserSchema)
+ user = fields.Nested(UserSchema(exclude=["username"]))
class Meta: # pylint: disable=too-few-public-methods
model = Query
diff --git a/superset/tags/schemas.py b/superset/tags/schemas.py
index 2081adf69f..71ab005bbc 100644
--- a/superset/tags/schemas.py
+++ b/superset/tags/schemas.py
@@ -45,7 +45,7 @@ class TaggedObjectEntityResponseSchema(Schema):
name = fields.String()
url = fields.String()
changed_on = fields.DateTime()
- created_by = fields.Nested(UserSchema)
+ created_by = fields.Nested(UserSchema(exclude=["username"]))
creator = fields.String()