mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
feat: annotations list CRUD view (#11446)
* annotations list CRUD view * comment out modal * update test * fix lint
This commit is contained in:
@@ -17,12 +17,17 @@
|
||||
from typing import Any, Dict
|
||||
|
||||
from flask_appbuilder import CompactCRUDMixin
|
||||
from flask_appbuilder.api import expose
|
||||
from flask_appbuilder.models.sqla.interface import SQLAInterface
|
||||
from flask_appbuilder.security.decorators import has_access
|
||||
from flask_babel import lazy_gettext as _
|
||||
from wtforms.validators import StopValidation
|
||||
|
||||
from superset import app
|
||||
from superset.constants import RouteMethod
|
||||
from superset.extensions import feature_flag_manager
|
||||
from superset.models.annotations import Annotation, AnnotationLayer
|
||||
from superset.typing import FlaskResponse
|
||||
from superset.views.base import SupersetModelView
|
||||
|
||||
|
||||
@@ -48,7 +53,7 @@ class AnnotationModelView(
|
||||
SupersetModelView, CompactCRUDMixin
|
||||
): # pylint: disable=too-many-ancestors
|
||||
datamodel = SQLAInterface(Annotation)
|
||||
include_route_methods = RouteMethod.CRUD_SET
|
||||
include_route_methods = RouteMethod.CRUD_SET | {"annotation"}
|
||||
|
||||
list_title = _("Annotations")
|
||||
show_title = _("Show Annotation")
|
||||
@@ -92,6 +97,17 @@ class AnnotationModelView(
|
||||
def pre_update(self, item: "AnnotationModelView") -> None:
|
||||
self.pre_add(item)
|
||||
|
||||
@expose("/<pk>/annotation/", methods=["GET"])
|
||||
@has_access
|
||||
def annotation(self, pk: int) -> FlaskResponse: # pylint: disable=unused-argument
|
||||
if not (
|
||||
app.config["ENABLE_REACT_CRUD_VIEWS"]
|
||||
and feature_flag_manager.is_feature_enabled("SIP_34_ANNOTATIONS_UI")
|
||||
):
|
||||
return super().list()
|
||||
|
||||
return super().render_app_template()
|
||||
|
||||
|
||||
class AnnotationLayerModelView(SupersetModelView): # pylint: disable=too-many-ancestors
|
||||
datamodel = SQLAInterface(AnnotationLayer)
|
||||
|
||||
Reference in New Issue
Block a user