feat: annotations list CRUD view (#11446)

* annotations list CRUD view

* comment out modal

* update test

* fix lint
This commit is contained in:
Lily Kuang
2020-10-28 12:19:50 -07:00
committed by GitHub
parent d4d547c30a
commit e5e35634de
8 changed files with 381 additions and 10 deletions

View File

@@ -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)