From f0f92ad1a12e8fac28be148d1ceb49d894baf025 Mon Sep 17 00:00:00 2001 From: konrad Date: Tue, 12 Jun 2018 19:57:38 +0200 Subject: [PATCH] Improved creation of list items --- models/list_items.go | 6 ++++++ models/list_items_create_update.go | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/models/list_items.go b/models/list_items.go index ff34d3ba..9858dbef 100644 --- a/models/list_items.go +++ b/models/list_items.go @@ -75,6 +75,12 @@ func GetListItemByID(listItemID int64) (listItem ListItem, err error) { return ListItem{}, ErrListItemDoesNotExist{listItemID} } + user, _, err := GetUserByID(listItem.CreatedByID) + if err != nil { + return + } + listItem.CreatedBy = user + return } diff --git a/models/list_items_create_update.go b/models/list_items_create_update.go index f5f2b9d6..60442cda 100644 --- a/models/list_items_create_update.go +++ b/models/list_items_create_update.go @@ -10,11 +10,12 @@ func CreateOrUpdateListItem(item *ListItem) (err error) { } // Check if the user exists - _, _, err = GetUserByID(item.CreatedBy.ID) + user, _, err := GetUserByID(item.CreatedBy.ID) if err != nil { return } item.CreatedByID = item.CreatedBy.ID + item.CreatedBy = user if item.ID != 0 { _, err = x.ID(item.ID).Update(item)