Added working explorer_profile_image upload.

This commit is contained in:
Marcus Scholz 2020-12-25 14:06:53 +01:00
parent 86cc7f23fe
commit 67ce6cb50b
2 changed files with 10 additions and 8 deletions

View File

@ -1,5 +1,4 @@
{% extends 'global.html'%} {% extends 'global.html'%}
{% load static %}
{% load i18n %} {% load i18n %}
{% load widget_tweaks %} {% load widget_tweaks %}

View File

@ -56,26 +56,29 @@ class ExplorerProfileUpdateView(IsAuthenticatedMixin, View):
return render(request, 'explorer/profile_update.html', context) return render(request, 'explorer/profile_update.html', context)
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
explorer_user_change_form = ExplorerUserChangeForm(request.POST, instance=request.user) explorer_user_change_form = ExplorerUserChangeForm(
explorer_change_form = ExplorerChangeForm(request.POST, instance=request.user.explorer) request.POST,
instance=request.user
)
explorer_change_form = ExplorerChangeForm(
request.POST,
request.FILES,
instance=request.user.explorer
)
if explorer_change_form.is_valid() and explorer_user_change_form.is_valid(): if explorer_change_form.is_valid() and explorer_user_change_form.is_valid():
explorer_user_change_form.save() explorer_user_change_form.save()
explorer_change_form.save() explorer_change_form.save()
#self.handle_place_images(request, explorer)
messages.success( messages.success(
self.request, self.request,
_('Successfully updated Explorer profile') _('Successfully updated Explorer profile')
) )
return redirect(reverse_lazy('explorer_profile_update'))
else: else:
# Usually the browser should have checked the form before sending. # Usually the browser should have checked the form before sending.
messages.error( messages.error(
self.request, self.request,
_('Please fill in all required fields.') _('Please fill in all required fields.')
) )
return redirect(reverse_lazy('explorer_profile_update')) return redirect(reverse_lazy('explorer_profile_update'))