Compare commits
No commits in common. "564d20c73e283d2c876d9e35fffed5bcef18689f" and "1eed5a8283ac5c321752a63f3c652f145c7d2f0a" have entirely different histories.
564d20c73e
...
1eed5a8283
@ -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,11 +70,10 @@ class HomeView(View):
|
|||||||
}
|
}
|
||||||
return render(request, 'home.html', context)
|
return render(request, 'home.html', context)
|
||||||
|
|
||||||
class PlaceUpdateView(IsAuthenticated, IsSubmitter, SuccessMessageMixin, UpdateView):
|
class PlaceUpdateView(IsAuthenticated, IsSubmitter, 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})
|
||||||
@ -111,19 +110,11 @@ 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):
|
||||||
@ -135,8 +126,8 @@ class PlaceCreateView(IsAuthenticated, View):
|
|||||||
)
|
)
|
||||||
place_image.save()
|
place_image.save()
|
||||||
|
|
||||||
class PlaceDeleteView(IsAuthenticated, IsSubmitter, SuccessMessageMixin, DeleteView):
|
class PlaceDeleteView(IsAuthenticated, IsSubmitter, 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