You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/11/21 16:51:05 UTC

[GitHub] [superset] villebro commented on a diff in pull request #22178: chore: remove annotation layer FAB CRUD model view

villebro commented on code in PR #22178:
URL: https://github.com/apache/superset/pull/22178#discussion_r1028291822


##########
superset/views/annotations.py:
##########
@@ -14,117 +14,27 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-from typing import Any, Dict
-
-from flask_appbuilder import CompactCRUDMixin
+from flask_appbuilder import permission_name
 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.constants import MODEL_VIEW_RW_METHOD_PERMISSION_MAP, RouteMethod
-from superset.models.annotations import Annotation, AnnotationLayer
 from superset.superset_typing import FlaskResponse
-from superset.views.base import SupersetModelView
-
-
-class StartEndDttmValidator:  # pylint: disable=too-few-public-methods
-    """
-    Validates dttm fields.
-    """
 
-    def __call__(self, form: Dict[str, Any], field: Any) -> None:
-        if not form["start_dttm"].data and not form["end_dttm"].data:
-            raise StopValidation(_("annotation start time or end time is required."))
-        if (
-            form["end_dttm"].data
-            and form["start_dttm"].data
-            and form["end_dttm"].data < form["start_dttm"].data
-        ):
-            raise StopValidation(
-                _("Annotation end time must be no earlier than start time.")
-            )

Review Comment:
   Note: I verified that the CRUD modal takes care of this validation in the frontend and that this validation is done in the command.
   
   Bycatch while checking the related code: This is trying to append the `Type` to `exceptions`, should be an instance of `AnnotationDatesValidationError`
   
   https://github.com/apache/superset/blob/ac0ff78616119bd5d8bebbb2781e0ef3486c4d19/superset/annotation_layers/annotations/commands/create.py#L73
   
   Why on earth is MyPy not picking this up?



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org