Simplified UpdatePlace success message using Mixin.
This commit is contained in:
parent
0cf482dc5c
commit
0b3aff1d1d
@ -70,14 +70,13 @@ 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):
|
||||
messages.success(
|
||||
self.request, 'Successfully updated place.')
|
||||
return reverse_lazy('place_detail', kwargs={'pk':self.get_object().pk})
|
||||
|
||||
class PlaceCreateView(IsAuthenticated, View):
|
||||
@ -136,8 +135,9 @@ 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_url = reverse_lazy('place_list')
|
||||
success_message = 'Successfully deleted place.'
|
||||
|
Loading…
Reference in New Issue
Block a user