Renamed list items to tasks

This commit is contained in:
konrad 2018-08-30 08:09:17 +02:00 committed by kolaente
parent d5758e0444
commit d31f16aff1
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
18 changed files with 249 additions and 249 deletions

View file

@ -5,7 +5,7 @@ Authorization: Bearer {{auth_token}}
### ###
# Get one list # Get one list
GET http://localhost:8080/api/v1/lists/28 GET http://localhost:8080/api/v1/lists/10
Authorization: Bearer {{auth_token}} Authorization: Bearer {{auth_token}}
### ###

View file

@ -201,55 +201,55 @@ func IsErrListTitleCannotBeEmpty(err error) bool {
} }
func (err ErrListTitleCannotBeEmpty) Error() string { func (err ErrListTitleCannotBeEmpty) Error() string {
return fmt.Sprintf("List item text cannot be empty.") return fmt.Sprintf("List task text cannot be empty.")
} }
// ================ // ================
// List item errors // List task errors
// ================ // ================
// ErrListItemCannotBeEmpty represents a "ErrListDoesNotExist" kind of error. Used if the list does not exist. // ErrListTaskCannotBeEmpty represents a "ErrListDoesNotExist" kind of error. Used if the list does not exist.
type ErrListItemCannotBeEmpty struct{} type ErrListTaskCannotBeEmpty struct{}
// IsErrListItemCannotBeEmpty checks if an error is a ErrListDoesNotExist. // IsErrListTaskCannotBeEmpty checks if an error is a ErrListDoesNotExist.
func IsErrListItemCannotBeEmpty(err error) bool { func IsErrListTaskCannotBeEmpty(err error) bool {
_, ok := err.(ErrListItemCannotBeEmpty) _, ok := err.(ErrListTaskCannotBeEmpty)
return ok return ok
} }
func (err ErrListItemCannotBeEmpty) Error() string { func (err ErrListTaskCannotBeEmpty) Error() string {
return fmt.Sprintf("List item text cannot be empty.") return fmt.Sprintf("List task text cannot be empty.")
} }
// ErrListItemDoesNotExist represents a "ErrListDoesNotExist" kind of error. Used if the list does not exist. // ErrListTaskDoesNotExist represents a "ErrListDoesNotExist" kind of error. Used if the list does not exist.
type ErrListItemDoesNotExist struct { type ErrListTaskDoesNotExist struct {
ID int64 ID int64
} }
// IsErrListItemDoesNotExist checks if an error is a ErrListDoesNotExist. // IsErrListTaskDoesNotExist checks if an error is a ErrListDoesNotExist.
func IsErrListItemDoesNotExist(err error) bool { func IsErrListTaskDoesNotExist(err error) bool {
_, ok := err.(ErrListItemDoesNotExist) _, ok := err.(ErrListTaskDoesNotExist)
return ok return ok
} }
func (err ErrListItemDoesNotExist) Error() string { func (err ErrListTaskDoesNotExist) Error() string {
return fmt.Sprintf("List item does not exist. [ID: %d]", err.ID) return fmt.Sprintf("List task does not exist. [ID: %d]", err.ID)
} }
// ErrNeedToBeItemOwner represents an error, where the user is not the owner of that item (used i.e. when deleting a list) // ErrNeedToBeTaskOwner represents an error, where the user is not the owner of that task (used i.e. when deleting a list)
type ErrNeedToBeItemOwner struct { type ErrNeedToBeTaskOwner struct {
ItemID int64 TaskID int64
UserID int64 UserID int64
} }
// IsErrNeedToBeItemOwner checks if an error is a ErrNeedToBeItemOwner. // IsErrNeedToBeTaskOwner checks if an error is a ErrNeedToBeTaskOwner.
func IsErrNeedToBeItemOwner(err error) bool { func IsErrNeedToBeTaskOwner(err error) bool {
_, ok := err.(ErrNeedToBeItemOwner) _, ok := err.(ErrNeedToBeTaskOwner)
return ok return ok
} }
func (err ErrNeedToBeItemOwner) Error() string { func (err ErrNeedToBeTaskOwner) Error() string {
return fmt.Sprintf("You need to be item owner to do that [ItemID: %d, UserID: %d]", err.ItemID, err.UserID) return fmt.Sprintf("You need to be task owner to do that [TaskID: %d, UserID: %d]", err.TaskID, err.UserID)
} }
// ================= // =================

View file

@ -1,6 +1,6 @@
package models package models
// List represents a list of items // List represents a list of tasks
type List struct { type List struct {
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"list"` ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"list"`
Title string `xorm:"varchar(250)" json:"title"` Title string `xorm:"varchar(250)" json:"title"`
@ -9,7 +9,7 @@ type List struct {
NamespaceID int64 `xorm:"int(11)" json:"-" param:"namespace"` NamespaceID int64 `xorm:"int(11)" json:"-" param:"namespace"`
Owner User `xorm:"-" json:"owner"` Owner User `xorm:"-" json:"owner"`
Items []*ListItem `xorm:"-" json:"items"` Tasks []*ListTask `xorm:"-" json:"tasks"`
Created int64 `xorm:"created" json:"created"` Created int64 `xorm:"created" json:"created"`
Updated int64 `xorm:"updated" json:"updated"` Updated int64 `xorm:"updated" json:"updated"`
@ -18,14 +18,14 @@ type List struct {
Rights `xorm:"-" json:"-"` Rights `xorm:"-" json:"-"`
} }
// AfterLoad loads the owner and list items // AfterLoad loads the owner and list tasks
func (l *List) AfterLoad() { func (l *List) AfterLoad() {
// Get the owner // Get the owner
l.Owner, _, _ = GetUserByID(l.OwnerID) l.Owner, _, _ = GetUserByID(l.OwnerID)
// Get the list items // Get the list tasks
l.Items, _ = GetItemsByListID(l.ID) l.Tasks, _ = GetTasksByListID(l.ID)
} }
// GetListByID returns a list by its ID // GetListByID returns a list by its ID

View file

@ -14,7 +14,7 @@ func (l *List) Delete() (err error) {
return return
} }
// Delete all todoitems on that list // Delete all todotasks on that list
_, err = x.Where("list_id = ?", l.ID).Delete(&ListItem{}) _, err = x.Where("list_id = ?", l.ID).Delete(&ListTask{})
return return
} }

View file

@ -1,14 +1,14 @@
package models package models
// ListItem represents an item in a todolist // ListTask represents an task in a todolist
type ListItem struct { type ListTask struct {
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"listitem"` ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"listtask"`
Text string `xorm:"varchar(250)" json:"text"` Text string `xorm:"varchar(250)" json:"text"`
Description string `xorm:"varchar(250)" json:"description"` Description string `xorm:"varchar(250)" json:"description"`
Done bool `json:"done"` Done bool `json:"done"`
DueDateUnix int64 `xorm:"int(11)" json:"dueDate"` DueDateUnix int64 `xorm:"int(11)" json:"dueDate"`
ReminderUnix int64 `xorm:"int(11)" json:"reminderDate"` ReminderUnix int64 `xorm:"int(11)" json:"reminderDate"`
CreatedByID int64 `xorm:"int(11)" json:"-"` // ID of the user who put that item on the list CreatedByID int64 `xorm:"int(11)" json:"-"` // ID of the user who put that task on the list
ListID int64 `xorm:"int(11)" json:"listID" param:"list"` ListID int64 `xorm:"int(11)" json:"listID" param:"list"`
Created int64 `xorm:"created" json:"created"` Created int64 `xorm:"created" json:"created"`
Updated int64 `xorm:"updated" json:"updated"` Updated int64 `xorm:"updated" json:"updated"`
@ -19,26 +19,26 @@ type ListItem struct {
Rights `xorm:"-" json:"-"` Rights `xorm:"-" json:"-"`
} }
// TableName returns the table name for listitems // TableName returns the table name for listtasks
func (ListItem) TableName() string { func (ListTask) TableName() string {
return "items" return "tasks"
} }
// GetItemsByListID gets all todoitems for a list // GetTasksByListID gets all todotasks for a list
func GetItemsByListID(listID int64) (items []*ListItem, err error) { func GetTasksByListID(listID int64) (tasks []*ListTask, err error) {
err = x.Where("list_id = ?", listID).Find(&items) err = x.Where("list_id = ?", listID).Find(&tasks)
if err != nil { if err != nil {
return return
} }
// No need to iterate over users if the list doesn't has items // No need to iterate over users if the list doesn't has tasks
if len(items) == 0 { if len(tasks) == 0 {
return return
} }
// Get all users and put them into the array // Get all users and put them into the array
var userIDs []int64 var userIDs []int64
for _, i := range items { for _, i := range tasks {
found := false found := false
for _, u := range userIDs { for _, u := range userIDs {
if i.CreatedByID == u { if i.CreatedByID == u {
@ -58,37 +58,37 @@ func GetItemsByListID(listID int64) (items []*ListItem, err error) {
return return
} }
for in, item := range items { for in, task := range tasks {
for _, user := range users { for _, user := range users {
if item.CreatedByID == user.ID { if task.CreatedByID == user.ID {
items[in].CreatedBy = user tasks[in].CreatedBy = user
break break
} }
} }
// obsfucate the user password // obsfucate the user password
items[in].CreatedBy.Password = "" tasks[in].CreatedBy.Password = ""
} }
return return
} }
// GetListItemByID returns all items a list has // GetListTaskByID returns all tasks a list has
func GetListItemByID(listItemID int64) (listItem ListItem, err error) { func GetListTaskByID(listTaskID int64) (listTask ListTask, err error) {
exists, err := x.ID(listItemID).Get(&listItem) exists, err := x.ID(listTaskID).Get(&listTask)
if err != nil { if err != nil {
return ListItem{}, err return ListTask{}, err
} }
if !exists { if !exists {
return ListItem{}, ErrListItemDoesNotExist{listItemID} return ListTask{}, ErrListTaskDoesNotExist{listTaskID}
} }
user, _, err := GetUserByID(listItem.CreatedByID) user, _, err := GetUserByID(listTask.CreatedByID)
if err != nil { if err != nil {
return return
} }
listItem.CreatedBy = user listTask.CreatedBy = user
return return
} }

View file

@ -1,30 +1,30 @@
package models package models
// Create is the implementation to create a list item // Create is the implementation to create a list task
func (i *ListItem) Create(doer *User) (err error) { func (i *ListTask) Create(doer *User) (err error) {
//i.ListID = lID //i.ListID = lID
i.ID = 0 i.ID = 0
return createOrUpdateListItem(i, doer) return createOrUpdateListTask(i, doer)
} }
// Update updates a list item // Update updates a list task
func (i *ListItem) Update() (err error) { func (i *ListTask) Update() (err error) {
// Check if the item exists // Check if the task exists
_, err = GetListItemByID(i.ID) _, err = GetListTaskByID(i.ID)
if err != nil { if err != nil {
return return
} }
return createOrUpdateListItem(i, &User{}) return createOrUpdateListTask(i, &User{})
} }
// Helper function for creation or updating of new lists as both methods share most of their logic // Helper function for creation or updating of new lists as both methods share most of their logic
func createOrUpdateListItem(i *ListItem, doer *User) (err error) { func createOrUpdateListTask(i *ListTask, doer *User) (err error) {
// Check if we have at least a text // Check if we have at least a text
if i.Text == "" { if i.Text == "" {
return ErrListItemCannotBeEmpty{} return ErrListTaskCannotBeEmpty{}
} }
// Check if the list exists // Check if the list exists

View file

@ -1,14 +1,14 @@
package models package models
// Delete implements the delete method for listItem // Delete implements the delete method for listTask
func (i *ListItem) Delete() (err error) { func (i *ListTask) Delete() (err error) {
// Check if it exists // Check if it exists
_, err = GetListItemByID(i.ID) _, err = GetListTaskByID(i.ID)
if err != nil { if err != nil {
return return
} }
_, err = x.ID(i.ID).Delete(ListItem{}) _, err = x.ID(i.ID).Delete(ListTask{})
return return
} }

View file

@ -1,28 +1,28 @@
package models package models
// CanDelete checks if the user can delete an item // CanDelete checks if the user can delete an task
func (i *ListItem) CanDelete(doer *User) bool { func (i *ListTask) CanDelete(doer *User) bool {
// Get the item // Get the task
lI, _ := GetListItemByID(i.ID) lI, _ := GetListTaskByID(i.ID)
// A user can delete an item if he has write acces to its list // A user can delete an task if he has write acces to its list
list, _ := GetListByID(lI.ListID) list, _ := GetListByID(lI.ListID)
return list.CanWrite(doer) return list.CanWrite(doer)
} }
// CanUpdate determines if a user has the right to update a list item // CanUpdate determines if a user has the right to update a list task
func (i *ListItem) CanUpdate(doer *User) bool { func (i *ListTask) CanUpdate(doer *User) bool {
// Get the item // Get the task
lI, _ := GetListItemByID(i.ID) lI, _ := GetListTaskByID(i.ID)
// A user can update an item if he has write acces to its list // A user can update an task if he has write acces to its list
list, _ := GetListByID(lI.ListID) list, _ := GetListByID(lI.ListID)
return list.CanWrite(doer) return list.CanWrite(doer)
} }
// CanCreate determines if a user has the right to create a list item // CanCreate determines if a user has the right to create a list task
func (i *ListItem) CanCreate(doer *User) bool { func (i *ListTask) CanCreate(doer *User) bool {
// A user can create an item if he has write acces to its list // A user can create an task if he has write acces to its list
list, _ := GetListByID(i.ListID) list, _ := GetListByID(i.ListID)
return list.CanWrite(doer) return list.CanWrite(doer)
} }

View file

@ -5,11 +5,11 @@ import (
"testing" "testing"
) )
func TestListItem_Create(t *testing.T) { func TestListTask_Create(t *testing.T) {
//assert.NoError(t, PrepareTestDatabase()) //assert.NoError(t, PrepareTestDatabase())
// Fake list item // Fake list task
listitem := ListItem{ listtask := ListTask{
Text: "Lorem", Text: "Lorem",
Description: "Lorem Ipsum BACKERY", Description: "Lorem Ipsum BACKERY",
ListID: 1, ListID: 1,
@ -19,56 +19,56 @@ func TestListItem_Create(t *testing.T) {
doer, _, err := GetUserByID(1) doer, _, err := GetUserByID(1)
assert.NoError(t, err) assert.NoError(t, err)
assert.True(t, listitem.CanCreate(&doer)) assert.True(t, listtask.CanCreate(&doer))
err = listitem.Create(&doer) err = listtask.Create(&doer)
assert.NoError(t, err) assert.NoError(t, err)
// Update it // Update it
listitem.Text = "Test34" listtask.Text = "Test34"
assert.True(t, listitem.CanUpdate(&doer)) assert.True(t, listtask.CanUpdate(&doer))
err = listitem.Update() err = listtask.Update()
assert.NoError(t, err) assert.NoError(t, err)
// Check if it was updated // Check if it was updated
li, err := GetListItemByID(listitem.ID) li, err := GetListTaskByID(listtask.ID)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, li.Text, "Test34") assert.Equal(t, li.Text, "Test34")
// Delete the item // Delete the task
assert.True(t, listitem.CanDelete(&doer)) assert.True(t, listtask.CanDelete(&doer))
err = listitem.Delete() err = listtask.Delete()
assert.NoError(t, err) assert.NoError(t, err)
// Delete a nonexistant item // Delete a nonexistant task
listitem.ID = 0 listtask.ID = 0
err = listitem.Delete() err = listtask.Delete()
assert.Error(t, err) assert.Error(t, err)
assert.True(t, IsErrListItemDoesNotExist(err)) assert.True(t, IsErrListTaskDoesNotExist(err))
// Try adding a list item with an empty text // Try adding a list task with an empty text
listitem.Text = "" listtask.Text = ""
err = listitem.Create(&doer) err = listtask.Create(&doer)
assert.Error(t, err) assert.Error(t, err)
assert.True(t, IsErrListItemCannotBeEmpty(err)) assert.True(t, IsErrListTaskCannotBeEmpty(err))
// Try adding one to a nonexistant list // Try adding one to a nonexistant list
listitem.ListID = 99993939 listtask.ListID = 99993939
listitem.Text = "Lorem Ipsum" listtask.Text = "Lorem Ipsum"
err = listitem.Create(&doer) err = listtask.Create(&doer)
assert.Error(t, err) assert.Error(t, err)
assert.True(t, IsErrListDoesNotExist(err)) assert.True(t, IsErrListDoesNotExist(err))
// Try updating a nonexistant item // Try updating a nonexistant task
listitem.ID = 94829352 listtask.ID = 94829352
err = listitem.Update() err = listtask.Update()
assert.Error(t, err) assert.Error(t, err)
assert.True(t, IsErrListItemDoesNotExist(err)) assert.True(t, IsErrListTaskDoesNotExist(err))
// Try inserting an item with a nonexistant user // Try inserting an task with a nonexistant user
nUser := &User{ID: 9482385} nUser := &User{ID: 9482385}
listitem.ListID = 1 listtask.ListID = 1
err = listitem.Create(nUser) err = listtask.Create(nUser)
assert.Error(t, err) assert.Error(t, err)
assert.True(t, IsErrUserDoesNotExist(err)) assert.True(t, IsErrUserDoesNotExist(err))
} }

View file

@ -34,7 +34,7 @@ func init() {
tables = append(tables, tables = append(tables,
new(User), new(User),
new(List), new(List),
new(ListItem), new(ListTask),
new(Team), new(Team),
new(TeamMember), new(TeamMember),
new(TeamList), new(TeamList),

View file

@ -15,18 +15,18 @@ func (n *Namespace) Delete() (err error) {
return return
} }
// Delete all lists with their items // Delete all lists with their tasks
lists, err := GetListsByNamespaceID(n.ID) lists, err := GetListsByNamespaceID(n.ID)
var listIDs []int64 var listIDs []int64
// We need to do that for here because we need the list ids to delete two times: // We need to do that for here because we need the list ids to delete two times:
// 1) to delete the lists itself // 1) to delete the lists itself
// 2) to delete the list items // 2) to delete the list tasks
for _, list := range lists { for _, list := range lists {
listIDs = append(listIDs, list.ID) listIDs = append(listIDs, list.ID)
} }
// Delete items // Delete tasks
_, err = x.In("list_id", listIDs).Delete(&ListItem{}) _, err = x.In("list_id", listIDs).Delete(&ListTask{})
if err != nil { if err != nil {
return return
} }

View file

@ -12,7 +12,7 @@ const (
const ( const (
// Can read lists in a Team // Can read lists in a Team
TeamRightRead TeamRight = iota TeamRightRead TeamRight = iota
// Can write items in a Team like lists and todo items. Cannot create new lists. // Can write tasks in a Team like lists and todo tasks. Cannot create new lists.
TeamRightWrite TeamRightWrite
// Can manage a list/namespace, can do everything // Can manage a list/namespace, can do everything
TeamRightAdmin TeamRightAdmin

View file

@ -2,87 +2,6 @@
"swagger": "2.0", "swagger": "2.0",
"info": {}, "info": {},
"paths": { "paths": {
"/items/{itemID}": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"lists"
],
"summary": "Updates a list item",
"operationId": "updateListItem",
"parameters": [
{
"type": "string",
"description": "ID of the item to update",
"name": "itemID",
"in": "path",
"required": true
},
{
"name": "body",
"in": "body",
"schema": {
"$ref": "#/definitions/ListItem"
}
}
],
"responses": {
"200": {
"$ref": "#/responses/ListItem"
},
"400": {
"$ref": "#/responses/Message"
},
"500": {
"$ref": "#/responses/Message"
}
}
},
"delete": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"lists"
],
"summary": "Deletes a list item",
"operationId": "deleteListItem",
"parameters": [
{
"type": "string",
"description": "ID of the list item to delete",
"name": "itemID",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"$ref": "#/responses/Message"
},
"400": {
"$ref": "#/responses/Message"
},
"403": {
"$ref": "#/responses/Message"
},
"404": {
"$ref": "#/responses/Message"
},
"500": {
"$ref": "#/responses/Message"
}
}
}
},
"/lists": { "/lists": {
"get": { "get": {
"consumes": [ "consumes": [
@ -117,7 +36,7 @@
"tags": [ "tags": [
"lists" "lists"
], ],
"summary": "gets one list with all todo items", "summary": "gets one list with all todo tasks",
"operationId": "getList", "operationId": "getList",
"parameters": [ "parameters": [
{ {
@ -150,8 +69,8 @@
"tags": [ "tags": [
"lists" "lists"
], ],
"summary": "Adds an item to a list", "summary": "Adds an task to a list",
"operationId": "addListItem", "operationId": "addListTask",
"parameters": [ "parameters": [
{ {
"type": "string", "type": "string",
@ -164,13 +83,13 @@
"name": "body", "name": "body",
"in": "body", "in": "body",
"schema": { "schema": {
"$ref": "#/definitions/ListItem" "$ref": "#/definitions/ListTask"
} }
} }
], ],
"responses": { "responses": {
"200": { "200": {
"$ref": "#/responses/ListItem" "$ref": "#/responses/ListTask"
}, },
"400": { "400": {
"$ref": "#/responses/Message" "$ref": "#/responses/Message"
@ -233,7 +152,7 @@
"tags": [ "tags": [
"lists" "lists"
], ],
"summary": "Deletes a list with all items on it", "summary": "Deletes a list with all tasks on it",
"operationId": "deleteList", "operationId": "deleteList",
"parameters": [ "parameters": [
{ {
@ -485,7 +404,7 @@
"tags": [ "tags": [
"namespaces" "namespaces"
], ],
"summary": "gets one namespace with all todo items", "summary": "gets one namespace with all todo tasks",
"operationId": "getNamespace", "operationId": "getNamespace",
"parameters": [ "parameters": [
{ {
@ -829,6 +748,87 @@
} }
} }
}, },
"/tasks/{taskID}": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"lists"
],
"summary": "Updates a list task",
"operationId": "updateListTask",
"parameters": [
{
"type": "string",
"description": "ID of the task to update",
"name": "taskID",
"in": "path",
"required": true
},
{
"name": "body",
"in": "body",
"schema": {
"$ref": "#/definitions/ListTask"
}
}
],
"responses": {
"200": {
"$ref": "#/responses/ListTask"
},
"400": {
"$ref": "#/responses/Message"
},
"500": {
"$ref": "#/responses/Message"
}
}
},
"delete": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"lists"
],
"summary": "Deletes a list task",
"operationId": "deleteListTask",
"parameters": [
{
"type": "string",
"description": "ID of the list task to delete",
"name": "taskID",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"$ref": "#/responses/Message"
},
"400": {
"$ref": "#/responses/Message"
},
"403": {
"$ref": "#/responses/Message"
},
"404": {
"$ref": "#/responses/Message"
},
"500": {
"$ref": "#/responses/Message"
}
}
}
},
"/teams": { "/teams": {
"get": { "get": {
"consumes": [ "consumes": [
@ -1125,7 +1125,7 @@
"x-go-package": "code.vikunja.io/api/models" "x-go-package": "code.vikunja.io/api/models"
}, },
"List": { "List": {
"description": "List represents a list of items", "description": "List represents a list of tasks",
"type": "object", "type": "object",
"properties": { "properties": {
"created": { "created": {
@ -1142,16 +1142,16 @@
"format": "int64", "format": "int64",
"x-go-name": "ID" "x-go-name": "ID"
}, },
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/ListItem"
},
"x-go-name": "Items"
},
"owner": { "owner": {
"$ref": "#/definitions/User" "$ref": "#/definitions/User"
}, },
"tasks": {
"type": "array",
"items": {
"$ref": "#/definitions/ListTask"
},
"x-go-name": "Tasks"
},
"title": { "title": {
"type": "string", "type": "string",
"x-go-name": "Title" "x-go-name": "Title"
@ -1164,8 +1164,8 @@
}, },
"x-go-package": "code.vikunja.io/api/models" "x-go-package": "code.vikunja.io/api/models"
}, },
"ListItem": { "ListTask": {
"description": "ListItem represents an item in a todolist", "description": "ListTask represents an task in a todolist",
"type": "object", "type": "object",
"properties": { "properties": {
"created": { "created": {
@ -1479,10 +1479,10 @@
"$ref": "#/definitions/List" "$ref": "#/definitions/List"
} }
}, },
"ListItem": { "ListTask": {
"description": "ListItem", "description": "ListTask",
"schema": { "schema": {
"$ref": "#/definitions/ListItem" "$ref": "#/definitions/ListTask"
} }
}, },
"Message": { "Message": {

View file

@ -18,7 +18,7 @@ type swaggerParameterBodies struct {
List models.List List models.List
// in:body // in:body
ListItem models.ListItem ListTask models.ListTask
// in:body // in:body
Namespace models.Namespace Namespace models.Namespace

View file

@ -44,11 +44,11 @@ type swaggerResponseLIst struct {
Body models.List `json:"body"` Body models.List `json:"body"`
} }
// ListItem // ListTask
// swagger:response ListItem // swagger:response ListTask
type swaggerResponseLIstItem struct { type swaggerResponseLIstTask struct {
// in:body // in:body
Body models.ListItem `json:"body"` Body models.ListTask `json:"body"`
} }
// ================ // ================

View file

@ -1,16 +1,16 @@
package v1 package v1
// swagger:operation DELETE /items/{itemID} lists deleteListItem // swagger:operation DELETE /tasks/{taskID} lists deleteListTask
// --- // ---
// summary: Deletes a list item // summary: Deletes a list task
// consumes: // consumes:
// - application/json // - application/json
// produces: // produces:
// - application/json // - application/json
// parameters: // parameters:
// - name: itemID // - name: taskID
// in: path // in: path
// description: ID of the list item to delete // description: ID of the list task to delete
// type: string // type: string
// required: true // required: true
// responses: // responses:
@ -27,7 +27,7 @@ package v1
// swagger:operation DELETE /lists/{listID} lists deleteList // swagger:operation DELETE /lists/{listID} lists deleteList
// --- // ---
// summary: Deletes a list with all items on it // summary: Deletes a list with all tasks on it
// consumes: // consumes:
// - application/json // - application/json
// produces: // produces:
@ -50,9 +50,9 @@ package v1
// "500": // "500":
// "$ref": "#/responses/Message" // "$ref": "#/responses/Message"
// swagger:operation PUT /lists/{listID} lists addListItem // swagger:operation PUT /lists/{listID} lists addListTask
// --- // ---
// summary: Adds an item to a list // summary: Adds an task to a list
// consumes: // consumes:
// - application/json // - application/json
// produces: // produces:
@ -66,35 +66,35 @@ package v1
// - name: body // - name: body
// in: body // in: body
// schema: // schema:
// "$ref": "#/definitions/ListItem" // "$ref": "#/definitions/ListTask"
// responses: // responses:
// "200": // "200":
// "$ref": "#/responses/ListItem" // "$ref": "#/responses/ListTask"
// "400": // "400":
// "$ref": "#/responses/Message" // "$ref": "#/responses/Message"
// "500": // "500":
// "$ref": "#/responses/Message" // "$ref": "#/responses/Message"
// swagger:operation POST /items/{itemID} lists updateListItem // swagger:operation POST /tasks/{taskID} lists updateListTask
// --- // ---
// summary: Updates a list item // summary: Updates a list task
// consumes: // consumes:
// - application/json // - application/json
// produces: // produces:
// - application/json // - application/json
// parameters: // parameters:
// - name: itemID // - name: taskID
// in: path // in: path
// description: ID of the item to update // description: ID of the task to update
// type: string // type: string
// required: true // required: true
// - name: body // - name: body
// in: body // in: body
// schema: // schema:
// "$ref": "#/definitions/ListItem" // "$ref": "#/definitions/ListTask"
// responses: // responses:
// "200": // "200":
// "$ref": "#/responses/ListItem" // "$ref": "#/responses/ListTask"
// "400": // "400":
// "$ref": "#/responses/Message" // "$ref": "#/responses/Message"
// "500": // "500":
@ -102,7 +102,7 @@ package v1
// swagger:operation GET /lists/{listID} lists getList // swagger:operation GET /lists/{listID} lists getList
// --- // ---
// summary: gets one list with all todo items // summary: gets one list with all todo tasks
// consumes: // consumes:
// - application/json // - application/json
// produces: // produces:
@ -321,7 +321,7 @@ package v1
// swagger:operation GET /namespaces/{namespaceID} namespaces getNamespace // swagger:operation GET /namespaces/{namespaceID} namespaces getNamespace
// --- // ---
// summary: gets one namespace with all todo items // summary: gets one namespace with all todo tasks
// consumes: // consumes:
// - application/json // - application/json
// produces: // produces:

View file

@ -38,8 +38,8 @@ func (c *WebHandler) CreateWeb(ctx echo.Context) error {
if models.IsErrListTitleCannotBeEmpty(err) { if models.IsErrListTitleCannotBeEmpty(err) {
return echo.NewHTTPError(http.StatusBadRequest, "You must provide at least a list title.") return echo.NewHTTPError(http.StatusBadRequest, "You must provide at least a list title.")
} }
if models.IsErrListItemCannotBeEmpty(err) { if models.IsErrListTaskCannotBeEmpty(err) {
return echo.NewHTTPError(http.StatusBadRequest, "You must provide at least a list item text.") return echo.NewHTTPError(http.StatusBadRequest, "You must provide at least a list task text.")
} }
if models.IsErrUserDoesNotExist(err) { if models.IsErrUserDoesNotExist(err) {
return echo.NewHTTPError(http.StatusBadRequest, "The user does not exist.") return echo.NewHTTPError(http.StatusBadRequest, "The user does not exist.")

View file

@ -96,12 +96,12 @@ func RegisterRoutes(e *echo.Echo) {
a.DELETE("/lists/:list", listHandler.DeleteWeb) a.DELETE("/lists/:list", listHandler.DeleteWeb)
a.PUT("/namespaces/:namespace/lists", listHandler.CreateWeb) a.PUT("/namespaces/:namespace/lists", listHandler.CreateWeb)
itemHandler := &crud.WebHandler{ taskHandler := &crud.WebHandler{
CObject: &models.ListItem{}, CObject: &models.ListTask{},
} }
a.PUT("/lists/:list", itemHandler.CreateWeb) a.PUT("/lists/:list", taskHandler.CreateWeb)
a.DELETE("/items/:listitem", itemHandler.DeleteWeb) a.DELETE("/tasks/:listtask", taskHandler.DeleteWeb)
a.POST("/items/:listitem", itemHandler.UpdateWeb) a.POST("/tasks/:listtask", taskHandler.UpdateWeb)
listTeamHandler := &crud.WebHandler{ listTeamHandler := &crud.WebHandler{
CObject: &models.TeamList{}, CObject: &models.TeamList{},