Issue is not overdue when it is on the same date #5566 (#5568)

* Due date time of issues and milestones is set to 23:59:59

* Add docs

* make gen swagger

* fix swagger gen
tokarchuk/v1.17
Rodrigo Villablanca Vásquez 6 years ago committed by Jonas Franz
parent 63bd1b9203
commit 4c52858c39
  1. 14
      routers/api/v1/repo/issue.go
  2. 2
      routers/repo/milestone.go
  3. 6
      templates/swagger/v1_json.tmpl

@ -9,6 +9,7 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"strings" "strings"
"time"
"code.gitea.io/gitea/models" "code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/context"
@ -144,7 +145,7 @@ func GetIssue(ctx *context.APIContext) {
func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) { func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) {
// swagger:operation POST /repos/{owner}/{repo}/issues issue issueCreateIssue // swagger:operation POST /repos/{owner}/{repo}/issues issue issueCreateIssue
// --- // ---
// summary: Create an issue // summary: Create an issue. If using deadline only the date will be taken into account, and time of day ignored.
// consumes: // consumes:
// - application/json // - application/json
// produces: // produces:
@ -236,7 +237,7 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) {
func EditIssue(ctx *context.APIContext, form api.EditIssueOption) { func EditIssue(ctx *context.APIContext, form api.EditIssueOption) {
// swagger:operation PATCH /repos/{owner}/{repo}/issues/{index} issue issueEditIssue // swagger:operation PATCH /repos/{owner}/{repo}/issues/{index} issue issueEditIssue
// --- // ---
// summary: Edit an issue // summary: Edit an issue. If using deadline only the date will be taken into account, and time of day ignored.
// consumes: // consumes:
// - application/json // - application/json
// produces: // produces:
@ -360,7 +361,7 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) {
func UpdateIssueDeadline(ctx *context.APIContext, form api.EditDeadlineOption) { func UpdateIssueDeadline(ctx *context.APIContext, form api.EditDeadlineOption) {
// swagger:operation POST /repos/{owner}/{repo}/issues/{index}/deadline issue issueEditIssueDeadline // swagger:operation POST /repos/{owner}/{repo}/issues/{index}/deadline issue issueEditIssueDeadline
// --- // ---
// summary: Set an issue deadline. If set to null, the deadline is deleted. // summary: Set an issue deadline. If set to null, the deadline is deleted. If using deadline only the date will be taken into account, and time of day ignored.
// consumes: // consumes:
// - application/json // - application/json
// produces: // produces:
@ -410,8 +411,11 @@ func UpdateIssueDeadline(ctx *context.APIContext, form api.EditDeadlineOption) {
} }
var deadlineUnix util.TimeStamp var deadlineUnix util.TimeStamp
var deadline time.Time
if form.Deadline != nil && !form.Deadline.IsZero() { if form.Deadline != nil && !form.Deadline.IsZero() {
deadlineUnix = util.TimeStamp(form.Deadline.Unix()) deadline = time.Date(form.Deadline.Year(), form.Deadline.Month(), form.Deadline.Day(),
23, 59, 59, 0, form.Deadline.Location())
deadlineUnix = util.TimeStamp(deadline.Unix())
} }
if err := models.UpdateIssueDeadline(issue, deadlineUnix, ctx.User); err != nil { if err := models.UpdateIssueDeadline(issue, deadlineUnix, ctx.User); err != nil {
@ -419,5 +423,5 @@ func UpdateIssueDeadline(ctx *context.APIContext, form api.EditDeadlineOption) {
return return
} }
ctx.JSON(201, api.IssueDeadline{Deadline: form.Deadline}) ctx.JSON(201, api.IssueDeadline{Deadline: &deadline})
} }

@ -113,6 +113,7 @@ func NewMilestonePost(ctx *context.Context, form auth.CreateMilestoneForm) {
return return
} }
deadline = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, deadline.Location())
if err = models.NewMilestone(&models.Milestone{ if err = models.NewMilestone(&models.Milestone{
RepoID: ctx.Repo.Repository.ID, RepoID: ctx.Repo.Repository.ID,
Name: form.Title, Name: form.Title,
@ -175,6 +176,7 @@ func EditMilestonePost(ctx *context.Context, form auth.CreateMilestoneForm) {
return return
} }
deadline = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, deadline.Location())
m, err := models.GetMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")) m, err := models.GetMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id"))
if err != nil { if err != nil {
if models.IsErrMilestoneNotExist(err) { if models.IsErrMilestoneNotExist(err) {

@ -1967,7 +1967,7 @@
"tags": [ "tags": [
"issue" "issue"
], ],
"summary": "Create an issue", "summary": "Create an issue. If using deadline only the date will be taken into account, and time of day ignored.",
"operationId": "issueCreateIssue", "operationId": "issueCreateIssue",
"parameters": [ "parameters": [
{ {
@ -2271,7 +2271,7 @@
"tags": [ "tags": [
"issue" "issue"
], ],
"summary": "Edit an issue", "summary": "Edit an issue. If using deadline only the date will be taken into account, and time of day ignored.",
"operationId": "issueEditIssue", "operationId": "issueEditIssue",
"parameters": [ "parameters": [
{ {
@ -2521,7 +2521,7 @@
"tags": [ "tags": [
"issue" "issue"
], ],
"summary": "Set an issue deadline. If set to null, the deadline is deleted.", "summary": "Set an issue deadline. If set to null, the deadline is deleted. If using deadline only the date will be taken into account, and time of day ignored.",
"operationId": "issueEditIssueDeadline", "operationId": "issueEditIssueDeadline",
"parameters": [ "parameters": [
{ {

Loading…
Cancel
Save