Beispiel #1
0
func ReleaseByName(ctx *middleware.Context) {
	rel, err := models.GetRelease(ctx.Repo.Repository.ID, ctx.Params(":release"))
	if err != nil {
		log.Error(4, "GetRelease: %v", err)
		ctx.Status(500)
		return
	}

	publisher, err := models.GetUserByID(rel.PublisherID)
	if err != nil {
		if models.IsErrUserNotExist(err) {
			publisher = models.NewFakeUser()
		} else {
			ctx.Handle(422, "GetUserByID", err)
			return
		}
	}
	rel.Publisher = publisher

	ctx.JSON(200, ToApiRelease(rel))
}
Beispiel #2
0
func EditRelease(ctx *middleware.Context, params martini.Params) {
	if !ctx.Repo.IsOwner {
		ctx.Handle(403, "release.ReleasesEdit", nil)
		return
	}

	tagName := params["tagname"]
	rel, err := models.GetRelease(ctx.Repo.Repository.Id, tagName)
	if err != nil {
		if err == models.ErrReleaseNotExist {
			ctx.Handle(404, "release.ReleasesEdit(GetRelease)", err)
		} else {
			ctx.Handle(500, "release.ReleasesEdit(GetRelease)", err)
		}
		return
	}
	ctx.Data["Release"] = rel

	ctx.Data["Title"] = "Edit Release"
	ctx.Data["IsRepoToolbarReleases"] = true
	ctx.HTML(200, RELEASE_EDIT)
}
Beispiel #3
0
func EditRelease(ctx *middleware.Context) {
	if !ctx.Repo.IsOwner() {
		ctx.Handle(403, "release.ReleasesEdit", nil)
		return
	}

	tagName := ctx.Params(":tagname")
	rel, err := models.GetRelease(ctx.Repo.Repository.Id, tagName)
	if err != nil {
		if err == models.ErrReleaseNotExist {
			ctx.Handle(404, "GetRelease", err)
		} else {
			ctx.Handle(500, "GetRelease", err)
		}
		return
	}
	ctx.Data["Release"] = rel

	ctx.Data["Title"] = ctx.Tr("repo.release.edit_release")
	ctx.Data["IsRepoToolbarReleases"] = true
	ctx.HTML(200, RELEASE_EDIT)
}
Beispiel #4
0
func EditRelease(ctx *middleware.Context) {
	ctx.Data["Title"] = ctx.Tr("repo.release.edit_release")
	ctx.Data["PageIsReleaseList"] = true
	ctx.Data["PageIsEditRelease"] = true

	tagName := ctx.Params(":tagname")
	rel, err := models.GetRelease(ctx.Repo.Repository.ID, tagName)
	if err != nil {
		if models.IsErrReleaseNotExist(err) {
			ctx.Handle(404, "GetRelease", err)
		} else {
			ctx.Handle(500, "GetRelease", err)
		}
		return
	}
	ctx.Data["tag_name"] = rel.TagName
	ctx.Data["tag_target"] = rel.Target
	ctx.Data["title"] = rel.Title
	ctx.Data["content"] = rel.Note
	ctx.Data["prerelease"] = rel.IsPrerelease

	ctx.HTML(200, RELEASE_NEW)
}
Beispiel #5
0
func EditReleasePost(ctx *context.Context, form auth.EditReleaseForm) {
	ctx.Data["Title"] = ctx.Tr("repo.release.edit_release")
	ctx.Data["PageIsReleaseList"] = true
	ctx.Data["PageIsEditRelease"] = true

	tagName := ctx.Params("*")
	rel, err := models.GetRelease(ctx.Repo.Repository.ID, tagName)
	if err != nil {
		if models.IsErrReleaseNotExist(err) {
			ctx.Handle(404, "GetRelease", err)
		} else {
			ctx.Handle(500, "GetRelease", err)
		}
		return
	}
	ctx.Data["tag_name"] = rel.TagName
	ctx.Data["tag_target"] = rel.Target
	ctx.Data["title"] = rel.Title
	ctx.Data["content"] = rel.Note
	ctx.Data["prerelease"] = rel.IsPrerelease

	if ctx.HasError() {
		ctx.HTML(200, RELEASE_NEW)
		return
	}

	rel.Title = form.Title
	rel.Note = form.Content
	rel.IsDraft = len(form.Draft) > 0
	rel.IsPrerelease = form.Prerelease
	if err = models.UpdateRelease(ctx.Repo.GitRepo, rel); err != nil {
		ctx.Handle(500, "UpdateRelease", err)
		return
	}
	ctx.Redirect(ctx.Repo.RepoLink + "/releases")
}
Beispiel #6
0
func EditReleasePost(ctx *middleware.Context, params martini.Params, form auth.EditReleaseForm) {
	if !ctx.Repo.IsOwner {
		ctx.Handle(403, "release.EditReleasePost", nil)
		return
	}

	tagName := params["tagname"]
	rel, err := models.GetRelease(ctx.Repo.Repository.Id, tagName)
	if err != nil {
		if err == models.ErrReleaseNotExist {
			ctx.Handle(404, "release.EditReleasePost(GetRelease)", err)
		} else {
			ctx.Handle(500, "release.EditReleasePost(GetRelease)", err)
		}
		return
	}
	ctx.Data["Release"] = rel

	if ctx.HasError() {
		ctx.HTML(200, RELEASE_EDIT)
		return
	}

	ctx.Data["Title"] = "Edit Release"
	ctx.Data["IsRepoToolbarReleases"] = true

	rel.Title = form.Title
	rel.Note = form.Content
	rel.IsDraft = len(form.Draft) > 0
	rel.IsPrerelease = form.Prerelease
	if err = models.UpdateRelease(ctx.Repo.GitRepo, rel); err != nil {
		ctx.Handle(500, "release.EditReleasePost(UpdateRelease)", err)
		return
	}
	ctx.Redirect(ctx.Repo.RepoLink + "/releases")
}