Пример #1
0
// POST /releases/delete
func ReleaseDelete(w rest.ResponseWriter, r *rest.Request) {
	r.ParseForm()
	id, _ := strconv.ParseInt(r.FormValue("Id"), 10, 64)
	release := database.FindRelease(id)
	file := database.FindFile(release.FileId)

	// Delete from DB
	database.DeleteRelease(release)
	database.UnpublishFile(file)
	go database.RefreshBuilds()

	// http.Redirect(w, r, "/admin/releases", http.StatusFound)
	w.WriteJson("")
}
Пример #2
0
// POST /releases/update
func ReleaseUpdate(w rest.ResponseWriter, r *rest.Request) {
	r.ParseForm()

	// Parse form and append to struct
	id, _ := strconv.ParseInt(r.FormValue("Id"), 10, 64)
	fileId, _ := strconv.ParseInt(r.FormValue("FileId"), 10, 64)
	release := database.FindRelease(id)
	file := database.FindFile(fileId)
	release.FileId = file.Id
	release.FileName = file.Name
	release.Channel = r.FormValue("Channel")
	release.Changelog = r.FormValue("Changelog")

	// Append to db
	database.UpdateRelease(release)

	// Redirect
	w.WriteJson("")
}
Пример #3
0
// GET releases/:id
func Release(w rest.ResponseWriter, r *rest.Request) {
	id, _ := strconv.ParseInt(r.PathParam("id"), 10, 64)
	release := releaseResource(database.FindRelease(id))
	w.WriteJson(apiResponse(r, release))
}