Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into right_panel_title
Browse files Browse the repository at this point in the history
  • Loading branch information
will-moore committed May 11, 2023
2 parents 950dea0 + ac66db9 commit c8b5760
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 5.19.1.dev0
current_version = 5.20.1.dev0
commit = True
tag = True
sign_tags = True
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
5.20.0 (May 2023)
-----------------

## Other changes

- Fix multi-file upload validation and support Django 3.2.19 security update [#465](https://github.com/ome/omero-web/pull/465)
- Declare portalocker as external dependency [#457](https://github.com/ome/omero-web/pull/457)

## Bug fixes

- Avoid creation of empty file annotations [#466](https://github.com/ome/omero-web/pull/466)

5.19.0 (March 2023)
-------------------

Expand Down
2 changes: 1 addition & 1 deletion omeroweb/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
omero_buildyear = "unknown"


omeroweb_version = "5.19.1.dev0"
omeroweb_version = "5.20.1.dev0"
omeroweb_buildyear = "2022"
21 changes: 21 additions & 0 deletions omeroweb/webclient/custom_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,3 +379,24 @@ def clean(self, value):
else:
final_values.append(val)
return final_values


# Custom widget and validation for multiple file uploads
# See https://docs.djangoproject.com/en/3.2/topics/http/
# file-uploads/#uploading-multiple-files
class MultipleFileInput(forms.ClearableFileInput):
allow_multiple_selected = True


class MultipleFileField(forms.FileField):
def __init__(self, *args, **kwargs):
kwargs.setdefault("widget", MultipleFileInput())
super().__init__(*args, **kwargs)

def clean(self, data, initial=None):
single_file_clean = super().clean
if isinstance(data, (list, tuple)):
result = [single_file_clean(d, initial) for d in data]
else:
result = single_file_clean(data, initial)
return result
5 changes: 2 additions & 3 deletions omeroweb/webclient/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

from omeroweb.custom_forms import NonASCIIForm
from .custom_forms import MetadataModelChoiceField
from .custom_forms import MultipleFileField
from .custom_forms import AnnotationModelMultipleChoiceField
from .custom_forms import ObjectModelMultipleChoiceField
from omeroweb.webadmin.custom_forms import ExperimenterModelMultipleChoiceField
Expand Down Expand Up @@ -334,9 +335,7 @@ def __init__(self, *args, **kwargs):
required=False,
)

annotation_file = forms.FileField(
widget=forms.ClearableFileInput(attrs={"multiple": True}), required=False
)
annotation_file = MultipleFileField(required=False)


class CommentAnnotationForm(BaseAnnotationForm):
Expand Down
4 changes: 3 additions & 1 deletion omeroweb/webclient/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2399,7 +2399,9 @@ def annotate_file(request, conn=None, **kwargs):

if request.method == "POST":
# handle form submission
form_file = FilesAnnotationForm(initial=initial, data=request.POST.copy())
form_file = FilesAnnotationForm(
initial=initial, data=request.POST.copy(), files=request.FILES
)
if form_file.is_valid():
# Link existing files...
files = form_file.cleaned_data["files"]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def read(fname):
"omero-py>=5.7.0",
# minimum requirements for `omero web start`
"concurrent-log-handler>=0.9.20",
"Django>=3.2.18,<4.0",
"Django>=3.2.19,<4.0",
"django-pipeline==2.0.7",
"django-cors-headers==3.7.0",
"whitenoise>=5.3.0",
Expand Down

0 comments on commit c8b5760

Please sign in to comment.