diff --git a/Featurecreep.md b/Featurecreep.md index c7937bb24fe..75e1380d0d4 100644 --- a/Featurecreep.md +++ b/Featurecreep.md @@ -165,7 +165,7 @@ Teams sind global, d.h. Ein Team kann mehrere Namespaces verwalten. * [ ] Assignees * [ ] Subtasks * [ ] Attachments -* [ ] Repeating tasks +* [x] Repeating tasks * [x] Tagesübersicht ("Was ist heute/diese Woche due?") -> Machen letztenendes die Clients, wir brauchen nur nen endpoint, der alle tasks auskotzt, der Client macht dann die Sortierung. * [ ] Tasks innerhalb eines definierbarem Bereich, sollte aber trotzdem der server machen, so à la "Gib mir alles für diesen Monat" * [ ] Namespaces in Namespaces (in Namespaces in Namespaces in Namespaces...) diff --git a/REST-Tests/lists.http b/REST-Tests/lists.http index 55a05df815e..5eee5ab9f1a 100644 --- a/REST-Tests/lists.http +++ b/REST-Tests/lists.http @@ -113,4 +113,13 @@ Authorization: Bearer {{auth_token}} GET http://localhost:8080/api/v1/tasks/caldav #Authorization: Bearer {{auth_token}} +### + +# Update a task +POST http://localhost:8080/api/v1/tasks/27 +Authorization: Bearer {{auth_token}} +Content-Type: application/json + +{"done":true} + ### \ No newline at end of file diff --git a/docs/docs.go b/docs/docs.go index f42fabb26f6..096c7a759cc 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -16,7 +16,7 @@ // GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // This file was generated by swaggo/swag at -// 2018-11-20 14:02:38.646137557 +0100 CET m=+0.072751301 +// 2018-11-26 18:08:08.504247606 +0100 CET m=+0.124662709 package docs @@ -107,7 +107,7 @@ var doc = `{ "ApiKeyAuth": [] } ], - "description": "Returns a list by its ID.", + "description": "Returns a team by its ID.", "consumes": [ "application/json" ], @@ -115,13 +115,13 @@ var doc = `{ "application/json" ], "tags": [ - "list" + "team" ], - "summary": "Gets one list", + "summary": "Gets one team", "parameters": [ { "type": "integer", - "description": "List ID", + "description": "Team ID", "name": "id", "in": "path", "required": true @@ -129,14 +129,14 @@ var doc = `{ ], "responses": { "200": { - "description": "The list", + "description": "The team", "schema": { "type": "object", - "$ref": "#/definitions/models.List" + "$ref": "#/definitions/models.Team" } }, "403": { - "description": "The user does not have access to the list", + "description": "The user does not have access to the team", "schema": { "type": "object", "$ref": "#/definitions/models.HTTPError" @@ -2910,6 +2910,9 @@ var doc = `{ "type": "integer" } }, + "repeatAfter": { + "type": "integer" + }, "text": { "type": "string" }, diff --git a/docs/swagger/swagger.json b/docs/swagger/swagger.json index e095eb720b0..180ebb1ea75 100644 --- a/docs/swagger/swagger.json +++ b/docs/swagger/swagger.json @@ -78,7 +78,7 @@ "ApiKeyAuth": [] } ], - "description": "Returns a list by its ID.", + "description": "Returns a team by its ID.", "consumes": [ "application/json" ], @@ -86,13 +86,13 @@ "application/json" ], "tags": [ - "list" + "team" ], - "summary": "Gets one list", + "summary": "Gets one team", "parameters": [ { "type": "integer", - "description": "List ID", + "description": "Team ID", "name": "id", "in": "path", "required": true @@ -100,14 +100,14 @@ ], "responses": { "200": { - "description": "The list", + "description": "The team", "schema": { "type": "object", - "$ref": "#/definitions/models.List" + "$ref": "#/definitions/models.Team" } }, "403": { - "description": "The user does not have access to the list", + "description": "The user does not have access to the team", "schema": { "type": "object", "$ref": "#/definitions/models.HTTPError" @@ -2881,6 +2881,9 @@ "type": "integer" } }, + "repeatAfter": { + "type": "integer" + }, "text": { "type": "string" }, diff --git a/docs/swagger/swagger.yaml b/docs/swagger/swagger.yaml index c78b48c68cc..ee77001ea55 100644 --- a/docs/swagger/swagger.yaml +++ b/docs/swagger/swagger.yaml @@ -64,6 +64,8 @@ definitions: items: type: integer type: array + repeatAfter: + type: integer text: type: string updated: @@ -389,9 +391,9 @@ paths: get: consumes: - application/json - description: Returns a list by its ID. + description: Returns a team by its ID. parameters: - - description: List ID + - description: Team ID in: path name: id required: true @@ -400,12 +402,12 @@ paths: - application/json responses: "200": - description: The list + description: The team schema: - $ref: '#/definitions/models.List' + $ref: '#/definitions/models.Team' type: object "403": - description: The user does not have access to the list + description: The user does not have access to the team schema: $ref: '#/definitions/models.HTTPError' type: object @@ -416,9 +418,9 @@ paths: type: object security: - ApiKeyAuth: [] - summary: Gets one list + summary: Gets one team tags: - - list + - team post: consumes: - application/json diff --git a/pkg/models/list_tasks.go b/pkg/models/list_tasks.go index c2f3852b7db..18a5a7fb3c9 100644 --- a/pkg/models/list_tasks.go +++ b/pkg/models/list_tasks.go @@ -26,6 +26,7 @@ type ListTask struct { RemindersUnix []int64 `xorm:"JSON TEXT" json:"reminderDates"` CreatedByID int64 `xorm:"int(11)" json:"-"` // ID of the user who put that task on the list ListID int64 `xorm:"int(11) INDEX" json:"listID" param:"list"` + RepeatAfter int64 `xorm:"int(11) INDEX" json:"repeatAfter"` Created int64 `xorm:"created" json:"created"` Updated int64 `xorm:"updated" json:"updated"` diff --git a/pkg/models/list_tasks_create_update.go b/pkg/models/list_tasks_create_update.go index 25c12e1ef7e..a5c15322594 100644 --- a/pkg/models/list_tasks_create_update.go +++ b/pkg/models/list_tasks_create_update.go @@ -55,7 +55,7 @@ func (i *ListTask) Create(doer *User) (err error) { i.CreatedByID = u.ID i.CreatedBy = u - _, err = x.Cols("text", "description", "done", "due_date_unix", "reminder_unix", "created_by_id", "list_id", "created", "updated").Insert(i) + _, err = x.Insert(i) return err } @@ -80,6 +80,17 @@ func (i *ListTask) Update() (err error) { return } + // When a repeating task is marked, as done, we update all deadlines and reminders and set it as undone + if !ot.Done && i.Done && ot.RepeatAfter > 0 { + ot.DueDateUnix = ot.DueDateUnix + ot.RepeatAfter + + for in, r := range ot.RemindersUnix { + ot.RemindersUnix[in] = r + ot.RepeatAfter + } + + i.Done = false + } + // For whatever reason, xorm dont detect if done is updated, so we need to update this every time by hand // Which is why we merge the actual task struct with the one we got from the // The user struct overrides values in the actual one. @@ -92,7 +103,7 @@ func (i *ListTask) Update() (err error) { ot.Done = false } - _, err = x.ID(i.ID).Cols("text", "description", "done", "due_date_unix", "reminders_unix").Update(ot) + _, err = x.ID(i.ID).Cols("text", "description", "done", "due_date_unix", "reminders_unix", "repeat_after").Update(ot) *i = ot return }