This is an automated email from the ASF dual-hosted git repository. maximebeauchemin pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push: new 209392e feat: make CRUD annotations inline (#9888) 209392e is described below commit 209392e9efaca0f2331e621745dd87959509dd8c Author: Maxime Beauchemin <maximebeauche...@gmail.com> AuthorDate: Tue Jun 2 23:12:37 2020 -0700 feat: make CRUD annotations inline (#9888) * feat: make CRUD annotations inline This makes the annotations inline of the "annotation layers". Originally they were setup as separate ModelViews because of a bug in FAB. * fix pylint --- superset/app.py | 10 +--------- superset/views/annotations.py | 27 +++++++++++++-------------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/superset/app.py b/superset/app.py index b1ce22c..98f1459 100644 --- a/superset/app.py +++ b/superset/app.py @@ -199,15 +199,6 @@ class SupersetAppInitializer: category_icon="", ) appbuilder.add_view( - AnnotationModelView, - "Annotations", - label=__("Annotations"), - icon="fa-comments", - category="Manage", - category_label=__("Manage"), - category_icon="", - ) - appbuilder.add_view( DatabaseView, "Databases", label=__("Databases"), @@ -288,6 +279,7 @@ class SupersetAppInitializer: appbuilder.add_view_no_menu(SliceAsync) appbuilder.add_view_no_menu(SqlLab) appbuilder.add_view_no_menu(SqlMetricInlineView) + appbuilder.add_view_no_menu(AnnotationModelView) appbuilder.add_view_no_menu(Superset) appbuilder.add_view_no_menu(TableColumnInlineView) appbuilder.add_view_no_menu(TableModelView) diff --git a/superset/views/annotations.py b/superset/views/annotations.py index 6d87972..e29883d 100644 --- a/superset/views/annotations.py +++ b/superset/views/annotations.py @@ -14,6 +14,7 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +from flask_appbuilder import CompactCRUDMixin from flask_appbuilder.models.sqla.interface import SQLAInterface from flask_babel import lazy_gettext as _ from wtforms.validators import StopValidation @@ -21,7 +22,7 @@ from wtforms.validators import StopValidation from superset.constants import RouteMethod from superset.models.annotations import Annotation, AnnotationLayer -from .base import DeleteMixin, SupersetModelView +from .base import SupersetModelView class StartEndDttmValidator: # pylint: disable=too-few-public-methods @@ -43,17 +44,17 @@ class StartEndDttmValidator: # pylint: disable=too-few-public-methods class AnnotationModelView( - SupersetModelView, DeleteMixin + SupersetModelView, CompactCRUDMixin ): # pylint: disable=too-many-ancestors datamodel = SQLAInterface(Annotation) include_route_methods = RouteMethod.CRUD_SET - list_title = _("List Annotation") + list_title = _("Annotations") show_title = _("Show Annotation") add_title = _("Add Annotation") edit_title = _("Edit Annotation") - list_columns = ["layer", "short_descr", "start_dttm", "end_dttm"] + list_columns = ["short_descr", "start_dttm", "end_dttm"] edit_columns = [ "layer", "short_descr", @@ -67,10 +68,10 @@ class AnnotationModelView( label_columns = { "layer": _("Layer"), - "short_descr": _("Short Descr"), - "start_dttm": _("Start Dttm"), - "end_dttm": _("End Dttm"), - "long_descr": _("Long Descr"), + "short_descr": _("Label"), + "long_descr": _("Description"), + "start_dttm": _("Start"), + "end_dttm": _("End"), "json_metadata": _("JSON Metadata"), } @@ -91,18 +92,16 @@ class AnnotationModelView( self.pre_add(item) -class AnnotationLayerModelView( - SupersetModelView, DeleteMixin -): # pylint: disable=too-many-ancestors +class AnnotationLayerModelView(SupersetModelView): # pylint: disable=too-many-ancestors datamodel = SQLAInterface(AnnotationLayer) include_route_methods = RouteMethod.CRUD_SET | {RouteMethod.API_READ} - - list_title = _("List Annotation Layer") + related_views = [AnnotationModelView] + list_title = _("Annotation Layers") show_title = _("Show Annotation Layer") add_title = _("Add Annotation Layer") edit_title = _("Edit Annotation Layer") - list_columns = ["id", "name"] + list_columns = ["name", "descr"] edit_columns = ["name", "descr"] add_columns = edit_columns