Compare commits
5 Commits
1eed5a8283
...
564d20c73e
Author | SHA1 | Date | |
---|---|---|---|
564d20c73e | |||
0b3aff1d1d | |||
0cf482dc5c | |||
275bec6560 | |||
852def01d2 |
@ -46,7 +46,7 @@ class SignUpView(SuccessMessageMixin, CreateView):
|
|||||||
form_class = ExplorerCreationForm
|
form_class = ExplorerCreationForm
|
||||||
success_url = reverse_lazy('login')
|
success_url = reverse_lazy('login')
|
||||||
template_name = 'signup.html'
|
template_name = 'signup.html'
|
||||||
success_message = 'User created'
|
success_message = 'User created.'
|
||||||
|
|
||||||
class PlaceListView(IsAuthenticated, View):
|
class PlaceListView(IsAuthenticated, View):
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
@ -70,10 +70,11 @@ class HomeView(View):
|
|||||||
}
|
}
|
||||||
return render(request, 'home.html', context)
|
return render(request, 'home.html', context)
|
||||||
|
|
||||||
class PlaceUpdateView(IsAuthenticated, IsSubmitter, UpdateView):
|
class PlaceUpdateView(IsAuthenticated, IsSubmitter, SuccessMessageMixin, UpdateView):
|
||||||
template_name = 'place/place_update.html'
|
template_name = 'place/place_update.html'
|
||||||
model = Place
|
model = Place
|
||||||
form_class = PlaceForm
|
form_class = PlaceForm
|
||||||
|
success_message = 'Successfully updated place.'
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return reverse_lazy('place_detail', kwargs={'pk':self.get_object().pk})
|
return reverse_lazy('place_detail', kwargs={'pk':self.get_object().pk})
|
||||||
@ -110,11 +111,19 @@ class PlaceCreateView(IsAuthenticated, View):
|
|||||||
kwargs_to_pass = {
|
kwargs_to_pass = {
|
||||||
'pk': place.pk
|
'pk': place.pk
|
||||||
}
|
}
|
||||||
|
|
||||||
|
messages.success(
|
||||||
|
self.request, 'Successfully created place.')
|
||||||
return redirect(reverse_lazy('place_detail', kwargs=kwargs_to_pass))
|
return redirect(reverse_lazy('place_detail', kwargs=kwargs_to_pass))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
context = {
|
context = {
|
||||||
'form': form_place
|
'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)
|
return render(request, 'place/place_create.html', context)
|
||||||
|
|
||||||
def _apply_multipart_image_upload(self, files, place, submitter):
|
def _apply_multipart_image_upload(self, files, place, submitter):
|
||||||
@ -126,8 +135,8 @@ class PlaceCreateView(IsAuthenticated, View):
|
|||||||
)
|
)
|
||||||
place_image.save()
|
place_image.save()
|
||||||
|
|
||||||
class PlaceDeleteView(IsAuthenticated, IsSubmitter, DeleteView):
|
class PlaceDeleteView(IsAuthenticated, IsSubmitter, SuccessMessageMixin, DeleteView):
|
||||||
template_name = 'place/place_delete.html'
|
template_name = 'place/place_delete.html'
|
||||||
model = Place
|
model = Place
|
||||||
|
success_message = 'Successfully deleted place.'
|
||||||
success_url = reverse_lazy('place_list')
|
success_url = reverse_lazy('place_list')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user