Use usual book widget for collection form view
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"git.artlef.fr/bibliomane/internal/adapter"
|
||||
"git.artlef.fr/bibliomane/internal/appcontext"
|
||||
"git.artlef.fr/bibliomane/internal/i18nresource"
|
||||
"git.artlef.fr/bibliomane/internal/myvalidator"
|
||||
@@ -36,18 +35,7 @@ func GetCollectionHandler(ac appcontext.AppContext) {
|
||||
myvalidator.ReturnErrorsAsJsonResponse(&ac, err)
|
||||
return
|
||||
}
|
||||
collectionBooksDb, err := query.FetchCollectionBooks(ac.Db, uint(collectionId), limit, offset)
|
||||
if err != nil {
|
||||
myvalidator.ReturnErrorsAsJsonResponse(&ac, err)
|
||||
return
|
||||
}
|
||||
collection := adapter.CollectionQueryToCollectionDto(collectionBooksDb)
|
||||
count, err := query.FetchCollectionBooksCount(ac.Db, uint(collectionId))
|
||||
if err != nil {
|
||||
myvalidator.ReturnErrorsAsJsonResponse(&ac, err)
|
||||
return
|
||||
}
|
||||
collection.Count = count
|
||||
collection, err := query.FetchCollectionHeader(ac.Db, uint(collectionId))
|
||||
if collection.UserID != user.ID {
|
||||
err := myvalidator.HttpError{
|
||||
StatusCode: http.StatusUnauthorized,
|
||||
@@ -55,7 +43,22 @@ func GetCollectionHandler(ac appcontext.AppContext) {
|
||||
}
|
||||
myvalidator.ReturnErrorsAsJsonResponse(&ac, err)
|
||||
return
|
||||
} else {
|
||||
ac.C.JSON(http.StatusOK, collection)
|
||||
}
|
||||
if err != nil {
|
||||
myvalidator.ReturnErrorsAsJsonResponse(&ac, err)
|
||||
return
|
||||
}
|
||||
books, err := query.FetchCollectionBooks(ac.Db, user.ID, uint(collectionId), limit, offset)
|
||||
if err != nil {
|
||||
myvalidator.ReturnErrorsAsJsonResponse(&ac, err)
|
||||
return
|
||||
}
|
||||
collection.Books = books
|
||||
count, err := query.FetchCollectionBooksCount(ac.Db, user.ID, uint(collectionId))
|
||||
if err != nil {
|
||||
myvalidator.ReturnErrorsAsJsonResponse(&ac, err)
|
||||
return
|
||||
}
|
||||
collection.Count = count
|
||||
ac.C.JSON(http.StatusOK, collection)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user