mirror of
https://github.com/gogs/gogs.git
synced 2025-07-07 19:19:08 +00:00
api/repo/milestone: fix change status didn't take effect
This commit is contained in:
parent
29722af1ae
commit
3f95824e65
@ -1405,6 +1405,10 @@ func (m *Milestone) State() api.StateType {
|
|||||||
return api.STATE_OPEN
|
return api.STATE_OPEN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Milestone) ChangeStatus(isClosed bool) error {
|
||||||
|
return ChangeMilestoneStatus(m, isClosed)
|
||||||
|
}
|
||||||
|
|
||||||
func (m *Milestone) APIFormat() *api.Milestone {
|
func (m *Milestone) APIFormat() *api.Milestone {
|
||||||
apiMilestone := &api.Milestone{
|
apiMilestone := &api.Milestone{
|
||||||
ID: m.ID,
|
ID: m.ID,
|
||||||
@ -1513,6 +1517,8 @@ func MilestoneStats(repoID int64) (open int64, closed int64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ChangeMilestoneStatus changes the milestone open/closed status.
|
// ChangeMilestoneStatus changes the milestone open/closed status.
|
||||||
|
// If milestone passes with changed values, those values will be
|
||||||
|
// updated to database as well.
|
||||||
func ChangeMilestoneStatus(m *Milestone, isClosed bool) (err error) {
|
func ChangeMilestoneStatus(m *Milestone, isClosed bool) (err error) {
|
||||||
repo, err := GetRepositoryByID(m.RepoID)
|
repo, err := GetRepositoryByID(m.RepoID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -81,10 +81,16 @@ func EditMilestone(ctx *context.APIContext, form api.EditMilestoneOption) {
|
|||||||
milestone.Deadline = *form.Deadline
|
milestone.Deadline = *form.Deadline
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := models.UpdateMilestone(milestone); err != nil {
|
if form.State != nil {
|
||||||
|
if err = milestone.ChangeStatus(api.STATE_CLOSED == api.StateType(*form.State)); err != nil {
|
||||||
|
ctx.Error(500, "ChangeStatus", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else if err = models.UpdateMilestone(milestone); err != nil {
|
||||||
ctx.Handle(500, "UpdateMilestone", err)
|
ctx.Handle(500, "UpdateMilestone", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.JSON(200, milestone.APIFormat())
|
ctx.JSON(200, milestone.APIFormat())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user