1
0
Fork 0

Check if the due_date is nil when editing issues (#32035)

(cherry picked from commit 3a51c37672d2fbad1f222922e75ce704d5a1ac71)
This commit is contained in:
Zettat123 2024-09-15 00:40:36 +08:00 committed by Earl Warren
parent 565084925a
commit 961766744b
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00

View file

@ -839,11 +839,17 @@ func EditIssue(ctx *context.APIContext) {
if (form.Deadline != nil || form.RemoveDeadline != nil) && canWrite { if (form.Deadline != nil || form.RemoveDeadline != nil) && canWrite {
var deadlineUnix timeutil.TimeStamp var deadlineUnix timeutil.TimeStamp
if (form.RemoveDeadline == nil || !*form.RemoveDeadline) && !form.Deadline.IsZero() { if form.RemoveDeadline == nil || !*form.RemoveDeadline {
if form.Deadline == nil {
ctx.Error(http.StatusBadRequest, "", "The due_date cannot be empty")
return
}
if !form.Deadline.IsZero() {
deadline := time.Date(form.Deadline.Year(), form.Deadline.Month(), form.Deadline.Day(), deadline := time.Date(form.Deadline.Year(), form.Deadline.Month(), form.Deadline.Day(),
23, 59, 59, 0, form.Deadline.Location()) 23, 59, 59, 0, form.Deadline.Location())
deadlineUnix = timeutil.TimeStamp(deadline.Unix()) deadlineUnix = timeutil.TimeStamp(deadline.Unix())
} }
}
if err := issues_model.UpdateIssueDeadline(ctx, issue, deadlineUnix, ctx.Doer); err != nil { if err := issues_model.UpdateIssueDeadline(ctx, issue, deadlineUnix, ctx.Doer); err != nil {
ctx.Error(http.StatusInternalServerError, "UpdateIssueDeadline", err) ctx.Error(http.StatusInternalServerError, "UpdateIssueDeadline", err)