Repeating tasks (#25)
This commit is contained in:
parent
3f44e3b83e
commit
06fc9f7886
7 changed files with 54 additions and 25 deletions
|
@ -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...)
|
||||
|
|
|
@ -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}
|
||||
|
||||
###
|
19
docs/docs.go
19
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"
|
||||
},
|
||||
|
|
|
@ -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"
|
||||
},
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"`
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue