half-working :P
This commit is contained in:
parent
17e71b71d4
commit
0f5474c2d3
@ -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'))
|
||||
|
Loading…
Reference in New Issue
Block a user