Implement download as zip for moments, calendar and folders #154
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
parent
5d92ece264
commit
946f7967b5
4 changed files with 47 additions and 5 deletions
|
@ -356,11 +356,7 @@ func DownloadAlbum(router *gin.RouterGroup, conf *config.Config) {
|
|||
return
|
||||
}
|
||||
|
||||
p, _, err := query.PhotoSearch(form.PhotoSearch{
|
||||
Album: a.AlbumUID,
|
||||
Count: 10000,
|
||||
Offset: 0,
|
||||
})
|
||||
p, err := query.AlbumPhotos(a, 10000)
|
||||
|
||||
if err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusNotFound, gin.H{"error": txt.UcFirst(err.Error())})
|
||||
|
|
|
@ -74,6 +74,24 @@ var AlbumFixtures = AlbumMap{
|
|||
UpdatedAt: time.Date(2020, 2, 1, 0, 0, 0, 0, time.UTC),
|
||||
DeletedAt: nil,
|
||||
},
|
||||
"april-1990": {
|
||||
ID: 1000003,
|
||||
CoverUID: "",
|
||||
AlbumUID: "at1lxuqipogaaba1",
|
||||
AlbumSlug: "april-1990",
|
||||
AlbumType: TypeFolder,
|
||||
AlbumTitle: "April 1990",
|
||||
AlbumDescription: "Spring is the time of year when many things change.",
|
||||
AlbumNotes: "Thunderstorms cause most of the severe spring weather.",
|
||||
AlbumOrder: "oldest",
|
||||
AlbumTemplate: "",
|
||||
AlbumFilter: "path:\"1990/04\"",
|
||||
AlbumFavorite: false,
|
||||
Links: []Link{},
|
||||
CreatedAt: time.Date(2019, 7, 1, 0, 0, 0, 0, time.UTC),
|
||||
UpdatedAt: time.Date(2020, 2, 1, 0, 0, 0, 0, time.UTC),
|
||||
DeletedAt: nil,
|
||||
},
|
||||
}
|
||||
|
||||
// CreateAlbumFixtures inserts known entities into the database for testing.
|
||||
|
|
|
@ -87,6 +87,18 @@ func AlbumCoverByUID(albumUID string) (file entity.File, err error) {
|
|||
return file, nil
|
||||
}
|
||||
|
||||
// AlbumPhotos returns up to count photos from an album.
|
||||
func AlbumPhotos(a entity.Album, count int) (results PhotoResults, err error) {
|
||||
results, _, err = PhotoSearch(form.PhotoSearch{
|
||||
Album: a.AlbumUID,
|
||||
Filter: a.AlbumFilter,
|
||||
Count: count,
|
||||
Offset: 0,
|
||||
})
|
||||
|
||||
return results, err
|
||||
}
|
||||
|
||||
// AlbumSearch searches albums based on their name.
|
||||
func AlbumSearch(f form.AlbumSearch) (results []AlbumResult, err error) {
|
||||
if err := f.ParseQueryString(); err != nil {
|
||||
|
|
|
@ -3,6 +3,7 @@ package query
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/photoprism/photoprism/internal/entity"
|
||||
form "github.com/photoprism/photoprism/internal/form"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
@ -43,6 +44,21 @@ func TestAlbumThumbByUID(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestAlbumPhotos(t *testing.T) {
|
||||
t.Run("search with string", func(t *testing.T) {
|
||||
results, err := AlbumPhotos(entity.AlbumFixtures.Get("april-1990"), 2)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if len(results) < 2 {
|
||||
t.Errorf("at least 2 results expected: %d", len(results))
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func TestAlbums(t *testing.T) {
|
||||
t.Run("search with string", func(t *testing.T) {
|
||||
query := form.NewAlbumSearch("chr")
|
||||
|
|
Loading…
Reference in a new issue