Improved creation of list items

This commit is contained in:
konrad 2018-06-12 19:57:38 +02:00 committed by kolaente
parent fc974fd87f
commit f0f92ad1a1
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
2 changed files with 8 additions and 1 deletions

View file

@ -75,6 +75,12 @@ func GetListItemByID(listItemID int64) (listItem ListItem, err error) {
return ListItem{}, ErrListItemDoesNotExist{listItemID} return ListItem{}, ErrListItemDoesNotExist{listItemID}
} }
user, _, err := GetUserByID(listItem.CreatedByID)
if err != nil {
return
}
listItem.CreatedBy = user
return return
} }

View file

@ -10,11 +10,12 @@ func CreateOrUpdateListItem(item *ListItem) (err error) {
} }
// Check if the user exists // Check if the user exists
_, _, err = GetUserByID(item.CreatedBy.ID) user, _, err := GetUserByID(item.CreatedBy.ID)
if err != nil { if err != nil {
return return
} }
item.CreatedByID = item.CreatedBy.ID item.CreatedByID = item.CreatedBy.ID
item.CreatedBy = user
if item.ID != 0 { if item.ID != 0 {
_, err = x.ID(item.ID).Update(item) _, err = x.ID(item.ID).Update(item)