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'%}
{% load static %}
{% load i18n %}
{% load widget_tweaks %}

View File

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