dashboards: add validation to delete dashboard by slug

Validates that there are only one folder/dashboard having that slug,
otherwise returns 412 Precondition Failed
This commit is contained in:
Marcus Efraimsson
2018-01-31 18:40:54 +01:00
parent 95d063621e
commit b23560ed5a
4 changed files with 73 additions and 1 deletions
+11
View File
@@ -386,3 +386,14 @@ func GetDashboardSlugById(query *m.GetDashboardSlugByIdQuery) error {
query.Result = slug.Slug
return nil
}
func GetDashboardsBySlug(query *m.GetDashboardsBySlugQuery) error {
var dashboards = make([]*m.Dashboard, 0)
if err := x.Where("org_id=? AND slug=?", query.OrgId, query.Slug).Find(&dashboards); err != nil {
return err
}
query.Result = dashboards
return nil
}