richardbarran / django-photologue

A customizable plug-in photo gallery management application for the Django web framework.
BSD 3-Clause "New" or "Revised" License
674 stars 239 forks source link

Add programmatic functionality for uploading zip file #222

Closed lausek closed 2 years ago

lausek commented 2 years ago

Hey maintainers,

first of all: Thanks your effort! You're keeping this project useful and alive!

I wanted to have a programmatic way of uploading zip files to the database. Something I could use inside the Django shell. At the moment, I'm utilizing UploadZipForm but it feels kind of clunky and it doesn't support setting a specific publishing date on the Gallery.

This PR refactors UploadZipForm.save into a new function:

def upload_photos_to_site(
    site: Site,
    zip: ZipFile,
    gallery: Gallery,
    photo_defaults: PhotoDefaults
) -> List[UploadMessage]:
    ...

TODO

richardbarran commented 2 years ago

Hello and thanks for the PR. Apologies for the delay in answering.

You code looks great. I like your idea of a separate upload method, and I like your use of typing. The only thing I'd want to change is dataclasses, as they might break Photologue for some users.

richardbarran commented 2 years ago

Hi Lausek - sorry for the delay. Your code looks great, I've merged it.