hughhhh commented on code in PR #20876: URL: https://github.com/apache/superset/pull/20876#discussion_r1086944341
########## superset/views/all_entities.py: ########## @@ -0,0 +1,262 @@ +# 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 __future__ import absolute_import, division, print_function, unicode_literals + +import logging +from typing import Any, Dict, List + +import simplejson as json +from flask import request, Response +from flask_appbuilder import expose +from flask_appbuilder.hooks import before_request +from flask_appbuilder.models.sqla.interface import SQLAInterface +from flask_appbuilder.security.decorators import has_access, has_access_api +from jinja2.sandbox import SandboxedEnvironment +from sqlalchemy import and_, func +from werkzeug.exceptions import NotFound + +from superset import db, is_feature_enabled, utils +from superset.jinja_context import ExtraCache +from superset.models.dashboard import Dashboard +from superset.models.slice import Slice +from superset.models.sql_lab import SavedQuery +from superset.superset_typing import FlaskResponse +from superset.tags.commands.create import CreateCustomTagCommand +from superset.tags.commands.exceptions import TagCreateFailedError, TagInvalidError +from superset.tags.models import ObjectTypes, Tag, TaggedObject +from superset.views.base import SupersetModelView + +from .base import BaseSupersetView, json_success + +logger = logging.getLogger(__name__) + + +def process_template(content: str) -> str: + env = SandboxedEnvironment() + template = env.from_string(content) + context = { + "current_user_id": ExtraCache.current_user_id, + "current_username": ExtraCache.current_username, + } + return template.render(context) + + +class TaggedObjectsModelView(SupersetModelView): + route_base = "/superset/all_entities" + datamodel = SQLAInterface(Tag) + class_permission_name = "Tags" + + @has_access + @expose("/") + def list(self) -> FlaskResponse: + if not is_feature_enabled("TAGGING_SYSTEM"): + return super().list() + + return super().render_app_template() + + +class TaggedObjectView(BaseSupersetView): Review Comment: can we move these endpoints under `tags/api`? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
