Add a delete brand image action on the APIv4 (#9552)

Этот коммит содержится в:
Julien Levesy
2018-10-15 16:46:26 +02:00
коммит произвёл George Goldberg
родитель 160d278592
Коммит 43bdbb0c3a
4 изменённых файлов: 68 добавлений и 0 удалений

Просмотреть файл

@@ -14,6 +14,7 @@ import (
func (api *API) InitBrand() {
api.BaseRoutes.Brand.Handle("/image", api.ApiHandlerTrustRequester(getBrandImage)).Methods("GET")
api.BaseRoutes.Brand.Handle("/image", api.ApiSessionRequired(uploadBrandImage)).Methods("POST")
api.BaseRoutes.Brand.Handle("/image", api.ApiSessionRequired(deleteBrandImage)).Methods("DELETE")
}
func getBrandImage(c *Context, w http.ResponseWriter, r *http.Request) {
@@ -71,3 +72,17 @@ func uploadBrandImage(c *Context, w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusCreated)
ReturnStatusOK(w)
}
func deleteBrandImage(c *Context, w http.ResponseWriter, r *http.Request) {
if !c.App.SessionHasPermissionTo(c.Session, model.PERMISSION_MANAGE_SYSTEM) {
c.SetPermissionError(model.PERMISSION_MANAGE_SYSTEM)
return
}
if err := c.App.DeleteBrandImage(); err != nil {
c.Err = err
return
}
ReturnStatusOK(w)
}