diff --git a/client/app/components/dashboards/edit-dashboard-dialog.html b/client/app/components/dashboards/edit-dashboard-dialog.html index edac266bfc..efd1bb7cc0 100644 --- a/client/app/components/dashboards/edit-dashboard-dialog.html +++ b/client/app/components/dashboards/edit-dashboard-dialog.html @@ -4,7 +4,7 @@
- +
diff --git a/redash/handlers/dashboards.py b/redash/handlers/dashboards.py index 1e0d3c6d54..2fa1aa9484 100644 --- a/redash/handlers/dashboards.py +++ b/redash/handlers/dashboards.py @@ -10,6 +10,7 @@ from redash.permissions import (can_modify, require_admin_or_owner, require_object_modify_permission, require_permission) +from sqlalchemy.exc import IntegrityError from sqlalchemy.orm.exc import StaleDataError @@ -154,6 +155,8 @@ def post(self, dashboard_slug): models.db.session.commit() except StaleDataError: abort(409) + except IntegrityError: + abort(400) result = dashboard.to_dict(with_widgets=True, user=self.current_user) return result diff --git a/redash/models.py b/redash/models.py index 9675838a14..e1354a72fc 100644 --- a/redash/models.py +++ b/redash/models.py @@ -1264,7 +1264,7 @@ class Dashboard(ChangeTrackingMixin, TimestampMixin, BelongsToOrgMixin, db.Model org_id = Column(db.Integer, db.ForeignKey("organizations.id")) org = db.relationship(Organization, backref="dashboards") slug = Column(db.String(140), index=True, default=generate_slug) - name = Column(db.String(100)) + name = Column(db.String(100), db.CheckConstraint("name<>''", name="dashboard_name_c")) user_id = Column(db.Integer, db.ForeignKey("users.id")) user = db.relationship(User) # TODO: The layout should dynamically be built from position and size information on each widget.