mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 14:13:21 +00:00
Sort pictures by album in zip file
This commit is contained in:
parent
a321bd79ed
commit
f265346a10
@ -80,6 +80,7 @@
|
|||||||
* @property {string} full_size_url
|
* @property {string} full_size_url
|
||||||
* @property {string} compressed_url
|
* @property {string} compressed_url
|
||||||
* @property {string} thumb_url
|
* @property {string} thumb_url
|
||||||
|
* @property {string} album
|
||||||
*/
|
*/
|
||||||
|
|
||||||
document.addEventListener("alpine:init", () => {
|
document.addEventListener("alpine:init", () => {
|
||||||
@ -104,7 +105,7 @@
|
|||||||
const zipWriter = new zip.ZipWriter(await fileHandle.createWritable());
|
const zipWriter = new zip.ZipWriter(await fileHandle.createWritable());
|
||||||
|
|
||||||
await Promise.all(pictures.map(p => {
|
await Promise.all(pictures.map(p => {
|
||||||
const img_name = "IMG_" + p.date.replaceAll(/[:\-]/g, "_") + p.name.slice(p.name.lastIndexOf("."));
|
const img_name = p.album + "/IMG_" + p.date.replaceAll(/[:\-]/g, "_") + p.name.slice(p.name.lastIndexOf("."));
|
||||||
return zipWriter.add(
|
return zipWriter.add(
|
||||||
img_name,
|
img_name,
|
||||||
new zip.HttpReader(p.full_size_url),
|
new zip.HttpReader(p.full_size_url),
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.db.models import F
|
||||||
from ninja import Query
|
from ninja import Query
|
||||||
from ninja_extra import ControllerBase, api_controller, route
|
from ninja_extra import ControllerBase, api_controller, route
|
||||||
from ninja_extra.exceptions import PermissionDenied
|
from ninja_extra.exceptions import PermissionDenied
|
||||||
@ -47,6 +48,7 @@ class PicturesController(ControllerBase):
|
|||||||
)
|
)
|
||||||
.distinct()
|
.distinct()
|
||||||
.order_by("-date")
|
.order_by("-date")
|
||||||
|
.annotate(album=F("parent__name"))
|
||||||
)
|
)
|
||||||
for picture in pictures:
|
for picture in pictures:
|
||||||
picture.full_size_url = picture.get_download_url()
|
picture.full_size_url = picture.get_download_url()
|
||||||
|
@ -23,6 +23,7 @@ class PictureSchema(ModelSchema):
|
|||||||
full_size_url: str
|
full_size_url: str
|
||||||
compressed_url: str
|
compressed_url: str
|
||||||
thumb_url: str
|
thumb_url: str
|
||||||
|
album: str
|
||||||
|
|
||||||
|
|
||||||
class PictureCreateRelationSchema(Schema):
|
class PictureCreateRelationSchema(Schema):
|
||||||
|
Loading…
Reference in New Issue
Block a user