Implemented basic api endpoint to manage deadlines
This commit is contained in:
parent
a98add1974
commit
1a905b2b8c
66
public/swagger.v1.json
vendored
66
public/swagger.v1.json
vendored
|
|
@ -2289,6 +2289,56 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/repos/{owner}/{repo}/issues/{index}/deadline": {
|
||||
"post": {
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"issue"
|
||||
],
|
||||
"summary": "Set an issue deadline",
|
||||
"operationId": "issueCreateIssueDeadline",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "owner of the repo",
|
||||
"name": "owner",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "name of the repo",
|
||||
"name": "repo",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "index of the issue to create or update a deadline on",
|
||||
"name": "index",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/CreateDeadlineOption"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"$ref": "#/responses/IssueDeadline"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/repos/{owner}/{repo}/issues/{index}/labels": {
|
||||
"get": {
|
||||
"produces": [
|
||||
|
|
@ -5470,6 +5520,21 @@
|
|||
},
|
||||
"x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea"
|
||||
},
|
||||
"CreateDeadlineOption": {
|
||||
"description": "CreateDeadlineOption options for creating a deadline",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"due_date"
|
||||
],
|
||||
"properties": {
|
||||
"due_date": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"x-go-name": "Deadline"
|
||||
}
|
||||
},
|
||||
"x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea"
|
||||
},
|
||||
"CreateEmailOption": {
|
||||
"description": "CreateEmailOption options when creating email addresses",
|
||||
"type": "object",
|
||||
|
|
@ -7675,6 +7740,7 @@
|
|||
"headers": {
|
||||
"AddCollaboratorOption": {},
|
||||
"AddTimeOption": {},
|
||||
"CreateDeadlineOption": {},
|
||||
"CreateEmailOption": {},
|
||||
"CreateForkOption": {},
|
||||
"CreateHookOption": {},
|
||||
|
|
|
|||
|
|
@ -446,6 +446,8 @@ func RegisterRoutes(m *macaron.Macaron) {
|
|||
m.Combo("").Get(repo.ListTrackedTimes).
|
||||
Post(reqToken(), bind(api.AddTimeOption{}), repo.AddTime)
|
||||
})
|
||||
|
||||
m.Combo("/deadline").Post(reqToken(), bind(api.CreateDeadlineOption{}), repo.UpdateIssueDeadline)
|
||||
})
|
||||
}, mustEnableIssues)
|
||||
m.Group("/labels", func() {
|
||||
|
|
|
|||
|
|
@ -333,3 +333,66 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) {
|
|||
}
|
||||
ctx.JSON(201, issue.APIFormat())
|
||||
}
|
||||
|
||||
// UpdateIssueDeadline updates an issue deadline
|
||||
func UpdateIssueDeadline(ctx *context.APIContext, form api.CreateDeadlineOption) {
|
||||
// swagger:operation POST /repos/{owner}/{repo}/issues/{index}/deadline issue issueCreateIssueDeadline
|
||||
// ---
|
||||
// summary: Set an issue deadline
|
||||
// consumes:
|
||||
// - application/json
|
||||
// produces:
|
||||
// - application/json
|
||||
// parameters:
|
||||
// - name: owner
|
||||
// in: path
|
||||
// description: owner of the repo
|
||||
// type: string
|
||||
// required: true
|
||||
// - name: repo
|
||||
// in: path
|
||||
// description: name of the repo
|
||||
// type: string
|
||||
// required: true
|
||||
// - name: index
|
||||
// in: path
|
||||
// description: index of the issue to create or update a deadline on
|
||||
// type: integer
|
||||
// required: true
|
||||
// - name: body
|
||||
// in: body
|
||||
// schema:
|
||||
// "$ref": "#/definitions/CreateDeadlineOption"
|
||||
// responses:
|
||||
// "201":
|
||||
// "$ref": "#/responses/IssueDeadline"
|
||||
|
||||
if !ctx.Repo.IsWriter() {
|
||||
ctx.JSON(401, map[string]string{
|
||||
"message": "Only users with write access to this repository can manage issue deadlines.",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||
if err != nil {
|
||||
if models.IsErrIssueNotExist(err) {
|
||||
ctx.Status(404)
|
||||
} else {
|
||||
ctx.Error(500, "GetIssueByIndex", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
var deadlineUnix util.TimeStamp
|
||||
if form.Deadline != nil && !form.Deadline.IsZero() {
|
||||
deadlineUnix = util.TimeStamp(form.Deadline.Unix())
|
||||
}
|
||||
|
||||
if err := models.UpdateIssueDeadline(issue, deadlineUnix, ctx.User); err != nil {
|
||||
ctx.Error(500, "UpdateIssueDeadline", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(201, api.IssueDeadline{Deadline:form.Deadline})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ type swaggerParameterBodies struct {
|
|||
|
||||
CreateIssueOption api.CreateIssueOption
|
||||
EditIssueOption api.EditIssueOption
|
||||
CreateDeadlineOption api.CreateDeadlineOption
|
||||
|
||||
CreateIssueCommentOption api.CreateIssueCommentOption
|
||||
EditIssueCommentOption api.EditIssueCommentOption
|
||||
|
|
|
|||
14
vendor/code.gitea.io/sdk/gitea/issue.go
generated
vendored
14
vendor/code.gitea.io/sdk/gitea/issue.go
generated
vendored
|
|
@ -138,3 +138,17 @@ func (c *Client) EditIssue(owner, repo string, index int64, opt EditIssueOption)
|
|||
return issue, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/%s/%s/issues/%d", owner, repo, index),
|
||||
jsonHeader, bytes.NewReader(body), issue)
|
||||
}
|
||||
|
||||
// CreateDeadlineOption options for creating a deadline
|
||||
type CreateDeadlineOption struct {
|
||||
// required:true
|
||||
// swagger:strfmt date-time
|
||||
Deadline *time.Time `json:"due_date"`
|
||||
}
|
||||
|
||||
// IssueDeadline represents an issue deadline
|
||||
// swagger:model
|
||||
type IssueDeadline struct {
|
||||
// swagger:strfmt date-time
|
||||
Deadline *time.Time `json:"due_date"`
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user