diff --git a/lostplaces/lostplaces_app/urls.py b/lostplaces/lostplaces_app/urls.py index caeda3a..2a2bbd7 100644 --- a/lostplaces/lostplaces_app/urls.py +++ b/lostplaces/lostplaces_app/urls.py @@ -1,8 +1,8 @@ from django.urls import path from .views import ( HomeView, - place_detail_view, - place_list_view, + PlaceDetailView, + PlaceListView, SignUpView, PlaceCreateView, PlaceUpdateView, @@ -12,9 +12,9 @@ from .views import ( urlpatterns = [ path('', HomeView.as_view(), name='home'), path('signup/', SignUpView.as_view(), name='signup'), - path('place//', place_detail_view, name='place_detail'), + path('place//', PlaceDetailView.as_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') + path('place/', PlaceListView.as_view(), name='place_list') ] diff --git a/lostplaces/lostplaces_app/views.py b/lostplaces/lostplaces_app/views.py index 0e6bfd2..878d3b9 100644 --- a/lostplaces/lostplaces_app/views.py +++ b/lostplaces/lostplaces_app/views.py @@ -45,11 +45,19 @@ class SignUpView(CreateView): success_url = reverse_lazy('login') template_name = 'signup.html' -def place_list_view(request,): - return render(request, 'place/place_list.html', {'place_list':Place.objects.all()}) +class PlaceListView(IsAuthenticated, View): + def get(request): + context = { + 'place_list': Place.objects.all() + } + return render(request, 'place/place_list.html', context) -def place_detail_view(request, pk): - return render(request, 'place/place_detail.html', {'place':Place.objects.get(pk=pk)}) +class PlaceDetailView(IsAuthenticated, View): + def get(request, pk): + context = { + 'place': Place.objects.get(pk=pk) + } + return render(request, 'place/place_detail.html', context) class HomeView(View): def get(self, request, *args, **kwargs):