From fded3c23d032d462b4503fff4f30deaa41ebce94 Mon Sep 17 00:00:00 2001 From: konrad Date: Wed, 21 Nov 2018 15:03:47 +0000 Subject: [PATCH] Multiple Reminders (#22) --- REST-Tests/auth.http | 2 +- docs/docs.go | 41 ++++++++++++++++++++++++++++--------- docs/swagger/swagger.json | 39 +++++++++++++++++++++++++++-------- docs/swagger/swagger.yaml | 32 +++++++++++++++++++++-------- pkg/models/list_tasks.go | 16 +++++++-------- pkg/routes/api/v1/caldav.go | 6 ++++-- 6 files changed, 97 insertions(+), 39 deletions(-) diff --git a/REST-Tests/auth.http b/REST-Tests/auth.http index acba01457e..7da9d12d3f 100644 --- a/REST-Tests/auth.http +++ b/REST-Tests/auth.http @@ -4,7 +4,7 @@ Content-Type: application/json { "username": "user", - "password": "12345" + "password": "1234" } > {% client.global.set("auth_token", response.body.token); %} diff --git a/docs/docs.go b/docs/docs.go index d4d98ce172..6a72cd0fb9 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -1,6 +1,6 @@ // GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // This file was generated by swaggo/swag at -// 2018-11-12 16:13:09.593331747 +0100 CET m=+0.083002310 +// 2018-11-20 14:02:38.646137557 +0100 CET m=+0.072751301 package docs @@ -91,7 +91,7 @@ var doc = `{ "ApiKeyAuth": [] } ], - "description": "Returns a team by its ID.", + "description": "Returns a list by its ID.", "consumes": [ "application/json" ], @@ -99,13 +99,13 @@ var doc = `{ "application/json" ], "tags": [ - "team" + "list" ], - "summary": "Gets one team", + "summary": "Gets one list", "parameters": [ { "type": "integer", - "description": "Team ID", + "description": "List ID", "name": "id", "in": "path", "required": true @@ -113,14 +113,14 @@ var doc = `{ ], "responses": { "200": { - "description": "The team", + "description": "The list", "schema": { "type": "object", - "$ref": "#/definitions/models.Team" + "$ref": "#/definitions/models.List" } }, "403": { - "description": "The user does not have access to the team", + "description": "The user does not have access to the list", "schema": { "type": "object", "$ref": "#/definitions/models.HTTPError" @@ -2888,8 +2888,11 @@ var doc = `{ "listID": { "type": "integer" }, - "reminderDate": { - "type": "integer" + "reminderDates": { + "type": "array", + "items": { + "type": "integer" + } }, "text": { "type": "string" @@ -3131,12 +3134,18 @@ var doc = `{ "admin": { "type": "boolean" }, + "created": { + "type": "integer" + }, "email": { "type": "string" }, "id": { "type": "integer" }, + "updated": { + "type": "integer" + }, "username": { "type": "string" } @@ -3178,12 +3187,18 @@ var doc = `{ "models.User": { "type": "object", "properties": { + "created": { + "type": "integer" + }, "email": { "type": "string" }, "id": { "type": "integer" }, + "updated": { + "type": "integer" + }, "username": { "type": "string" } @@ -3203,6 +3218,9 @@ var doc = `{ "models.UserWithRight": { "type": "object", "properties": { + "created": { + "type": "integer" + }, "email": { "type": "string" }, @@ -3212,6 +3230,9 @@ var doc = `{ "right": { "type": "integer" }, + "updated": { + "type": "integer" + }, "username": { "type": "string" } diff --git a/docs/swagger/swagger.json b/docs/swagger/swagger.json index 9f41369c37..e095eb720b 100644 --- a/docs/swagger/swagger.json +++ b/docs/swagger/swagger.json @@ -78,7 +78,7 @@ "ApiKeyAuth": [] } ], - "description": "Returns a team by its ID.", + "description": "Returns a list by its ID.", "consumes": [ "application/json" ], @@ -86,13 +86,13 @@ "application/json" ], "tags": [ - "team" + "list" ], - "summary": "Gets one team", + "summary": "Gets one list", "parameters": [ { "type": "integer", - "description": "Team ID", + "description": "List ID", "name": "id", "in": "path", "required": true @@ -100,14 +100,14 @@ ], "responses": { "200": { - "description": "The team", + "description": "The list", "schema": { "type": "object", - "$ref": "#/definitions/models.Team" + "$ref": "#/definitions/models.List" } }, "403": { - "description": "The user does not have access to the team", + "description": "The user does not have access to the list", "schema": { "type": "object", "$ref": "#/definitions/models.HTTPError" @@ -2875,8 +2875,11 @@ "listID": { "type": "integer" }, - "reminderDate": { - "type": "integer" + "reminderDates": { + "type": "array", + "items": { + "type": "integer" + } }, "text": { "type": "string" @@ -3118,12 +3121,18 @@ "admin": { "type": "boolean" }, + "created": { + "type": "integer" + }, "email": { "type": "string" }, "id": { "type": "integer" }, + "updated": { + "type": "integer" + }, "username": { "type": "string" } @@ -3165,12 +3174,18 @@ "models.User": { "type": "object", "properties": { + "created": { + "type": "integer" + }, "email": { "type": "string" }, "id": { "type": "integer" }, + "updated": { + "type": "integer" + }, "username": { "type": "string" } @@ -3190,6 +3205,9 @@ "models.UserWithRight": { "type": "object", "properties": { + "created": { + "type": "integer" + }, "email": { "type": "string" }, @@ -3199,6 +3217,9 @@ "right": { "type": "integer" }, + "updated": { + "type": "integer" + }, "username": { "type": "string" } diff --git a/docs/swagger/swagger.yaml b/docs/swagger/swagger.yaml index a5f4b9e254..c78b48c68c 100644 --- a/docs/swagger/swagger.yaml +++ b/docs/swagger/swagger.yaml @@ -60,8 +60,10 @@ definitions: type: integer listID: type: integer - reminderDate: - type: integer + reminderDates: + items: + type: integer + type: array text: type: string updated: @@ -219,10 +221,14 @@ definitions: properties: admin: type: boolean + created: + type: integer email: type: string id: type: integer + updated: + type: integer username: type: string type: object @@ -250,10 +256,14 @@ definitions: type: object models.User: properties: + created: + type: integer email: type: string id: type: integer + updated: + type: integer username: type: string type: object @@ -266,12 +276,16 @@ definitions: type: object models.UserWithRight: properties: + created: + type: integer email: type: string id: type: integer right: type: integer + updated: + type: integer username: type: string type: object @@ -375,9 +389,9 @@ paths: get: consumes: - application/json - description: Returns a team by its ID. + description: Returns a list by its ID. parameters: - - description: Team ID + - description: List ID in: path name: id required: true @@ -386,12 +400,12 @@ paths: - application/json responses: "200": - description: The team + description: The list schema: - $ref: '#/definitions/models.Team' + $ref: '#/definitions/models.List' type: object "403": - description: The user does not have access to the team + description: The user does not have access to the list schema: $ref: '#/definitions/models.HTTPError' type: object @@ -402,9 +416,9 @@ paths: type: object security: - ApiKeyAuth: [] - summary: Gets one team + summary: Gets one list tags: - - team + - list post: consumes: - application/json diff --git a/pkg/models/list_tasks.go b/pkg/models/list_tasks.go index 734eb7531d..d867c29360 100644 --- a/pkg/models/list_tasks.go +++ b/pkg/models/list_tasks.go @@ -2,14 +2,14 @@ package models // ListTask represents an task in a todolist type ListTask struct { - ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"listtask"` - Text string `xorm:"varchar(250)" json:"text" valid:"runelength(5|250)"` - Description string `xorm:"varchar(250)" json:"description" valid:"runelength(0|250)"` - Done bool `xorm:"INDEX" json:"done"` - DueDateUnix int64 `xorm:"int(11) INDEX" json:"dueDate"` - ReminderUnix int64 `xorm:"int(11) INDEX" json:"reminderDate"` - 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"` + ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"listtask"` + Text string `xorm:"varchar(250)" json:"text" valid:"runelength(5|250)"` + Description string `xorm:"varchar(250)" json:"description" valid:"runelength(0|250)"` + Done bool `xorm:"INDEX" json:"done"` + DueDateUnix int64 `xorm:"int(11) INDEX" json:"dueDate"` + 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"` Created int64 `xorm:"created" json:"created" valid:"range(0|0)"` Updated int64 `xorm:"updated" json:"updated" valid:"range(0|0)"` diff --git a/pkg/routes/api/v1/caldav.go b/pkg/routes/api/v1/caldav.go index ea42120853..4140acc030 100644 --- a/pkg/routes/api/v1/caldav.go +++ b/pkg/routes/api/v1/caldav.go @@ -54,8 +54,10 @@ func Caldav(c echo.Context) error { EndUnix: t.DueDateUnix + hour, } - if t.ReminderUnix != 0 { - event.Alarms = append(event.Alarms, caldav.Alarm{TimeUnix: t.ReminderUnix}) + if len(t.RemindersUnix) > 0 { + for _, rem := range t.RemindersUnix { + event.Alarms = append(event.Alarms, caldav.Alarm{TimeUnix: rem}) + } } caldavTasks = append(caldavTasks, event)