Improved creation of list items
This commit is contained in:
parent
fc974fd87f
commit
f0f92ad1a1
2 changed files with 8 additions and 1 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue