UpdateApplication updates an application info by its id. swagger:operation PUT /application/{id} application updateApplication Update an application. --- consumes: [application/json] produces: [application/json] security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQ
(ctx *gin.Context)
| 248 | // schema: |
| 249 | // $ref: "#/definitions/Error" |
| 250 | func (a *ApplicationAPI) UpdateApplication(ctx *gin.Context) { |
| 251 | withID(ctx, "id", func(id uint) { |
| 252 | app, err := a.DB.GetApplicationByID(id) |
| 253 | if success := successOrAbort(ctx, 500, err); !success { |
| 254 | return |
| 255 | } |
| 256 | if app != nil && app.UserID == auth.GetUserID(ctx) { |
| 257 | applicationParams := ApplicationParams{} |
| 258 | if err := ctx.Bind(&applicationParams); err == nil { |
| 259 | app.Description = applicationParams.Description |
| 260 | app.Name = applicationParams.Name |
| 261 | app.DefaultPriority = applicationParams.DefaultPriority |
| 262 | if applicationParams.SortKey != "" { |
| 263 | app.SortKey = applicationParams.SortKey |
| 264 | } |
| 265 | |
| 266 | if err := a.DB.UpdateApplication(app); err != nil { |
| 267 | handleApplicationError(ctx, err) |
| 268 | return |
| 269 | } |
| 270 | ctx.JSON(200, withResolvedImage(app)) |
| 271 | } |
| 272 | } else { |
| 273 | ctx.AbortWithError(404, fmt.Errorf("app with id %d doesn't exists", id)) |
| 274 | } |
| 275 | }) |
| 276 | } |
| 277 | |
| 278 | // UploadApplicationImage uploads an image for an application. |
| 279 | // swagger:operation POST /application/{id}/image application uploadAppImage |
nothing calls this directly
no test coverage detected