Small refactoring

This commit is contained in:
reverend 2020-07-30 22:33:41 +02:00
parent fc4167ffc2
commit 2fa4874c08
2 changed files with 6 additions and 5 deletions

View File

@ -25,8 +25,8 @@ class PlaceImageCreateForm(forms.ModelForm):
fields = '__all__' fields = '__all__'
exclude = ['submitted_by', 'place', 'description'] exclude = ['submitted_by', 'place', 'description']
widgets = { widgets = {
'filename': forms.ClearableFileInput(attrs={'multiple': True}), 'filename': forms.ClearableFileInput(attrs={'multiple': True})
}, }
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)

View File

@ -51,9 +51,9 @@ class PlaceEditView(View):
if request.FILES: if request.FILES:
self._apply_multipart_image_upload( self._apply_multipart_image_upload(
request.FILES.getlist('filename'), files=request.FILES.getlist('filename'),
place, place=place,
submitter submitter=submitter
) )
kwargs_to_pass = { kwargs_to_pass = {
@ -67,6 +67,7 @@ class PlaceEditView(View):
return render(request, 'create_place.html', context) return render(request, 'create_place.html', context)
def _apply_multipart_image_upload(self, files, place, submitter): def _apply_multipart_image_upload(self, files, place, submitter):
print(files)
for image in files: for image in files:
place_image = PlaceImage.objects.create( place_image = PlaceImage.objects.create(
filename=image, filename=image,