forked from bit/django-async-upload
-
Notifications
You must be signed in to change notification settings - Fork 0
Admin form UI improvements and multi file upload support #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
0ca379d
update resumablejs
paigewilliams 8b5a269
display percent uploading in UI
paigewilliams ece7e20
rename package
paigewilliams 8e4c010
add middleware and admin mixin to track and delete file
paigewilliams 6f76b72
add tests for middleware
paigewilliams c4aae87
allow for specific GET requests in form before clearing session
paigewilliams 2de7fb0
comment out broken tests; add requirements.txt
paigewilliams f271f2c
include pause/resume and cancel buttons
paigewilliams 70f404f
support multiple uploads with max_files param
paigewilliams 7c55a05
track multiple files in session
paigewilliams 0879cf3
allow for deleting uploaded file
paigewilliams 98c2099
fix removing orphaned file on multiple chunked upload
paigewilliams 975c235
display thumbnails for media and bulk media uploads
paigewilliams 854ff04
fix selenium test
paigewilliams 8f75d8a
use chrome for selenium test; make test less flaky
paigewilliams 311e17f
cancel all button works
paigewilliams 54121c8
add test for cancelling single file upload
paigewilliams 8ffd1ce
add test for cancelling all uploads
paigewilliams 1eb1836
add test for pause/resume buttons
paigewilliams e5ba99b
verify progress bar with pause/resume
paigewilliams c2cd65c
add test for error state on upload
paigewilliams 8d355f3
add test for multiple file uploads
paigewilliams 462e2f6
fix tests
paigewilliams f6c32a0
use css classes instead of inline styles
paigewilliams c5d7acf
use storages instead of DEFAULT_FILE_STORAGE to resolve django warnings
paigewilliams d14d8df
allow for configurable chunk folder
paigewilliams 440b474
add docs
paigewilliams 631779f
fix readme and setup.py issues
paigewilliams d0ccc26
make tests less flaky
paigewilliams 003e90b
remove middleware and mixin
paigewilliams 2354789
formatting, logging fix
paigewilliams bf47ea1
add deconstruct method to AsyncFileField
paigewilliams 213f82f
add tests for storages
paigewilliams 0dfce28
remove unused import
paigewilliams 60f7082
add FormResumableMultipleFileField to use allow_multiple_selected att…
paigewilliams 0d7497d
cleaner error handling in UploadView.delete
paigewilliams 57b14bc
clean up tests
paigewilliams fc963e1
use tuple in exception
paigewilliams bb51201
use escapejs when accessing MEDIA_URL
paigewilliams b96793b
add switch case for form_class in AsyncFileField depending on max_fil…
paigewilliams d7f021c
always use RormResumableFileField in AsyncFileField
paigewilliams 3ab1ea8
wip: github action to run tests
paigewilliams ddb06fe
install requirements.txt in gh action
paigewilliams e0ec5df
add wait for clickable element in tests
paigewilliams ba1aa08
try adding chrome and chromedriver to gh action
paigewilliams 43d5ece
try installing chrome via apt-get
paigewilliams 6fbd322
keep waiting for button
paigewilliams 773878c
try larger file for pause/resume test
paigewilliams c88ab6d
Revert "try larger file for pause/resume test"
paigewilliams 28367a6
ignore test_upload.py in gh action
paigewilliams 0280f68
fix typo
paigewilliams bdd2496
try playwright
paigewilliams 41db358
declare file_path out of try/except
paigewilliams a6a2b8c
apply ruff format
paigewilliams ae18dae
initalize package with uv
paigewilliams 9eb5341
bump versions
paigewilliams 31b45b9
fix urls and file paths
paigewilliams 35e9bd6
use python version 3.11
paigewilliams File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| name: Run Tests | ||
|
|
||
| on: [push, pull_request] | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Run Tests | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v5 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: "3.10" | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r requirements.txt | ||
|
|
||
| - name: Install Playwright browsers | ||
| run: python -m playwright install --with-deps chromium | ||
|
|
||
| - name: Run tests | ||
| run: pytest --tracing=retain-on-failure | ||
|
|
||
| - uses: actions/upload-artifact@v4 | ||
| if: ${{ !cancelled() }} | ||
| with: | ||
| name: playwright-traces | ||
| path: test-results/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 3.11 |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| # django-resumable-async-upload | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. markdown > rst |
||
|
|
||
| django-resumable-async-upload is a django app to allow you to upload large files from within the django admin site asynchronously, that means that you can add any number of files on the admin page (e.g. through inline models) and continue editing other fields while files are uploading. | ||
|
|
||
| - Currently only tested with the Django default file storage | ||
|
|
||
| ## Installation | ||
|
|
||
| - pip install django-resumable-async-upload | ||
| - Add `django_resumable_async_upload` to your `INSTALLED_APPS` | ||
| - Add `re_path(r"^django_resumable_async_upload/", include("django_resumable_async_upload.urls")),` to your urls.py | ||
| - Add in your models field | ||
|
|
||
| ``` | ||
| from django_resumable_async_upload.models import AsyncFileField | ||
|
|
||
| class Foo(models.Model): | ||
| bar = models.CharField(max_length=200) | ||
| foo = AsyncFileField() | ||
| ``` | ||
|
|
||
| - Add in your admin form: | ||
|
|
||
| ``` | ||
| from django_resumable_async_upload.fields import FormResumableMultipleFileField | ||
| from django_resumable_async_upload.widgets import ResumableAdminWidget | ||
|
|
||
| class MultiUploadForm(forms.ModelForm): | ||
| files = FormResumableMultipleFileField( | ||
| required=False, | ||
| widget=ResumableAdminWidget(attrs={"model": File, "field_name": "file"}), | ||
| ) | ||
| ``` | ||
|
|
||
| Optional Settings: | ||
|
|
||
| - Set `ADMIN_RESUMABLE_CHUNKSIZE`, default is `"1*1024*1024"` | ||
| - Set `ADMIN_RESUMABLE_STORAGE`, default is setting of storages and ultimately `'django.core.files.storage.FileSystemStorage'`. If you don't want the default FileSystemStorage behaviour of creating new files on the server with filenames appended with \_1, \_2, etc for consecutive uploads of the same file, then you could use this to set your storage class to something like https://djangosnippets.org/snippets/976/ | ||
| - Set `ADMIN_RESUMABLE_CHUNK_STORAGE`, default is `'django.core.files.storage.FileSystemStorage'` . If you don't want the default FileSystemStorage behaviour of creating new files on the server with filenames appended with \_1, \_2, etc for consecutive uploads of the same file, then you could use this to set your storage class to something like https://djangosnippets.org/snippets/976/ | ||
| - Set `ADMIN_RESUMABLE_SHOW_THUMB`, default is False. Shows a thumbnail next to the "Currently:" link. | ||
| - Set `ADMIN_SIMULTANEOUS_UPLOADS` to limit number of simultaneous uploads, defaults to `3`. If you have broken pipe issues in local development environment, set this value to `1`. | ||
| - Set `MEDIA_URL` to where images are stored to be rendered after upload | ||
|
|
||
| Optional Param for `AsyncFileField` | ||
|
|
||
| - `max_files`, default is None. Configure how many files are allowed to be uploaded to a file input. | ||
|
|
||
| ## Versions | ||
|
|
||
| 0.1.0 - inital fork of django-async-upload 4.0.1 with support for Django 4 and later. Includes admin form updates to pause, resume, cancel and track progress of upload. Also supports uploads of multiple files | ||
|
|
||
| ## Compatibility | ||
|
|
||
| Tested on Django 4.2 running on python 3.12 | ||
|
|
||
| ## Thanks to | ||
|
|
||
| original django-admin-resumable-js by jonatron https://github.com/jonatron/django-admin-resumable-js | ||
|
|
||
| django-admin-resumable-js fork by roxel https://github.com/roxel/django-admin-resumable-js | ||
|
|
||
| django-admin-async-upload fork by DataGreed https://github.com/DataGreed/django-admin-async-upload | ||
|
|
||
| django-async-upload fork by bit https://github.com/bit/django-async-upload | ||
|
|
||
| Resumable.js https://github.com/23/resumable.js | ||
|
|
||
| Typescript supported version of resumable.js https://github.com/augustcodes08/resumable-uploads | ||
|
|
||
| django-resumable https://github.com/jeanphix/django-resumable | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to get selenium tests to work and didnt seem like worth the effort. If time allows, it might be worth looking into using something like playwright instead considering they have better docs on how to run in a GH action https://playwright.dev/python/docs/ci-intro
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copilot was EXTREMELY helpful in migrating to playwright! wooooo