Compare commits

..

2 Commits

Author SHA1 Message Date
0f5474c2d3 half-working :P 2020-12-25 11:14:21 +01:00
17e71b71d4 Fix typo. 2020-12-25 08:04:35 +01:00
2 changed files with 13 additions and 12 deletions

View File

@ -88,7 +88,7 @@ msgstr "Profilbild"
#: models/models.py:56
msgid "Optional profile image for display in Explorer profile"
msgstr "Optionales Profilbind zur Anzeige im Explorerprofil"
msgstr "Optionales Profilbild zur Anzeige im Explorerprofil"
#: models/place.py:21
msgid "Location"

View File

@ -7,6 +7,7 @@ from django.utils.translation import ugettext_lazy as _
from django.shortcuts import render, redirect, get_object_or_404
from django.urls import reverse_lazy
from django.contrib import messages
from lostplaces.common import get_all_subclasses
from lostplaces.views.base_views import IsAuthenticatedMixin
@ -55,22 +56,21 @@ class ExplorerProfileUpdateView(IsAuthenticatedMixin, View):
return render(request, 'explorer/profile_update.html', context)
def post(self, request, *args, **kwargs):
explorer_change_form = ExplorerChangeForm(request.POST)
explorer_user_change_form = ExplorerUserChangeForm(request.POST, instance=request.user)
explorer_change_form = ExplorerChangeForm(request.POST, instance=request.user.explorer)
if place_form.is_valid():
submitter = request.user.explorer
place = place_form.save(commit=False)
# Save logged in user as "submitted_by"
place.submitted_by = submitter
place.save()
if explorer_change_form.is_valid() and explorer_user_change_form.is_valid():
print(explorer_user_change_form)
explorer_user_change_form.save()
explorer_change_form.save()
self.handle_place_images(request, place)
#self.handle_place_images(request, explorer)
messages.success(
self.request,
_('Successfully created place')
_('Successfully updated Explorer profile')
)
return redirect(reverse_lazy('place_detail', kwargs={'pk': place.pk}))
return redirect(reverse_lazy('explorer_profile_update'))
else:
# Usually the browser should have checked the form before sending.
@ -78,4 +78,5 @@ class ExplorerProfileUpdateView(IsAuthenticatedMixin, View):
self.request,
_('Please fill in all required fields.')
)
return render(request, 'place/place_create.html', context={'form': place_form})
return redirect(reverse_lazy('explorer_profile_update'))