This commit is contained in:
+16
-2
@@ -8,7 +8,7 @@ from django.views.generic import ListView, UpdateView
|
||||
|
||||
from .forms import SearchProfileForm
|
||||
from .models import SearchProfile
|
||||
from .services import save_profile_revision
|
||||
from .services import resolve_profile_home_location, save_profile_revision
|
||||
|
||||
|
||||
class ProfileListView(LoginRequiredMixin, ListView):
|
||||
@@ -31,10 +31,24 @@ class ProfileUpdateView(LoginRequiredMixin, UpdateView):
|
||||
|
||||
def form_valid(self, form):
|
||||
response = super().form_valid(form)
|
||||
location_result = resolve_profile_home_location(self.object)
|
||||
if self.object.is_active:
|
||||
self.object.activate()
|
||||
save_profile_revision(self.object, reason="user_edit")
|
||||
messages.success(self.request, "Zoekprofiel opgeslagen.")
|
||||
if self.object.home_postal_code and location_result.ambiguous:
|
||||
messages.warning(
|
||||
self.request,
|
||||
"Zoekprofiel opgeslagen. Deze postcode omvat meerdere gemeenten; afstand blijft "
|
||||
"onbekend tot de lokale geodata eenduidig is.",
|
||||
)
|
||||
elif self.object.home_postal_code and location_result.location is None:
|
||||
messages.warning(
|
||||
self.request,
|
||||
"Zoekprofiel opgeslagen. De postcode is bewaard; lokale geodata ontbreekt nog "
|
||||
"voor een afstandsberekening.",
|
||||
)
|
||||
else:
|
||||
messages.success(self.request, "Zoekprofiel opgeslagen.")
|
||||
return response
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user