示例#1
0
func AlbumDelete(args martini.Params, req *http.Request, r render.Render, su models.User, dbh *db.Dbh, p *models.Page) {
	// Default status
	var result string = "Not Deleted"
	var status string = "Permission Denied"
	var code int = 401

	name := args["name"]

	album := dbh.GetAlbumByName(name)
	if album.User == su.Id {
		status = "Success"
		result = "Deleted"
		dAlbum := dbh.AlbumDelete(album)
		log.Printf("%+v", dAlbum)
	}
	if album.Id == 0 {
		status = "Album not found"
		code = 404
	}

	p.Data = models.AlbumResult{Name: name, Result: result, Status: status}
	log.Println("Album Delete: User: "******" Album: ", name, " Result: ", result, " Status: ", status)
	encoder.Render("json", code, "", p, r)
}