diff --git a/lostplaces/lostplaces_app/forms.py b/lostplaces/lostplaces_app/forms.py index d88d090..8650e92 100644 --- a/lostplaces/lostplaces_app/forms.py +++ b/lostplaces/lostplaces_app/forms.py @@ -48,3 +48,8 @@ class PlaceImageCreateForm(forms.ModelForm): super().__init__(*args, **kwargs) self.fields['filename'].required = False + +class PlaceDeleteForm(forms.ModelForm): + class Meta: + model = Place + fields = ['name'] diff --git a/lostplaces/lostplaces_app/urls.py b/lostplaces/lostplaces_app/urls.py index c810057..f741f29 100644 --- a/lostplaces/lostplaces_app/urls.py +++ b/lostplaces/lostplaces_app/urls.py @@ -6,7 +6,8 @@ from .views import ( place_list_view, SignUpView, PlaceCreateView, - PlaceUpdateView + PlaceUpdateView, + PlaceDeleteView ) urlpatterns = [ @@ -16,5 +17,6 @@ urlpatterns = [ path('place//', place_detail_view, name='place_detail'), path('place/create/', PlaceCreateView.as_view(), name='place_create'), path('place/update//', PlaceUpdateView.as_view(), name='place_edit'), + path('place/delete//', PlaceDeleteView.as_view(), name='place_delete'), path('place/', place_list_view, name='place_list') ] diff --git a/lostplaces/lostplaces_app/views.py b/lostplaces/lostplaces_app/views.py index 8e97fe2..bc8a19e 100644 --- a/lostplaces/lostplaces_app/views.py +++ b/lostplaces/lostplaces_app/views.py @@ -9,7 +9,12 @@ from django.views import View from django.http import Http404 from django.views.generic.edit import UpdateView -from .forms import ExplorerCreationForm, PlaceForm, PlaceImageCreateForm +from .forms import ( + ExplorerCreationForm, + PlaceForm, + PlaceImageCreateForm, + PlaceDeleteForm +) from .models import Place, PlaceImage, Voucher # Create your views here. @@ -90,3 +95,14 @@ class PlaceCreateView(View): submitted_by=submitter ) place_image.save() + +class PlaceDeleteView(View): + template_name = 'delete_place.html' + model = Place + form_class = PlaceDeleteForm + + def get(self, request, *args, **kwargs): + place_delete_form = PlaceDeleteForm() + + context = {'place_form': place_delete_form} + return render(request, 'create_place.html', context)