Compare commits

..

5 Commits

View File

@ -46,7 +46,7 @@ class SignUpView(SuccessMessageMixin, CreateView):
form_class = ExplorerCreationForm
success_url = reverse_lazy('login')
template_name = 'signup.html'
success_message = 'User created'
success_message = 'User created.'
class PlaceListView(IsAuthenticated, View):
def get(self, request):
@ -70,10 +70,11 @@ class HomeView(View):
}
return render(request, 'home.html', context)
class PlaceUpdateView(IsAuthenticated, IsSubmitter, UpdateView):
class PlaceUpdateView(IsAuthenticated, IsSubmitter, SuccessMessageMixin, UpdateView):
template_name = 'place/place_update.html'
model = Place
form_class = PlaceForm
success_message = 'Successfully updated place.'
def get_success_url(self):
return reverse_lazy('place_detail', kwargs={'pk':self.get_object().pk})
@ -110,11 +111,19 @@ class PlaceCreateView(IsAuthenticated, View):
kwargs_to_pass = {
'pk': place.pk
}
messages.success(
self.request, 'Successfully created place.')
return redirect(reverse_lazy('place_detail', kwargs=kwargs_to_pass))
else:
context = {
'form': form_place
}
# Usually the browser should have checked the form before sending.
messages.error(
self.request, 'Please fill in all required fields.')
return render(request, 'place/place_create.html', context)
def _apply_multipart_image_upload(self, files, place, submitter):
@ -126,8 +135,8 @@ class PlaceCreateView(IsAuthenticated, View):
)
place_image.save()
class PlaceDeleteView(IsAuthenticated, IsSubmitter, DeleteView):
class PlaceDeleteView(IsAuthenticated, IsSubmitter, SuccessMessageMixin, DeleteView):
template_name = 'place/place_delete.html'
model = Place
success_message = 'Successfully deleted place.'
success_url = reverse_lazy('place_list')