Handle HomeView for unauthenticated users with separate template.
This commit is contained in:
parent
843832d978
commit
91c888db8f
@ -8,6 +8,7 @@ from django.shortcuts import render, redirect
|
||||
|
||||
from lostplaces_app.forms import ExplorerCreationForm
|
||||
from lostplaces_app.models import Place, PhotoAlbum
|
||||
from lostplaces_app.views import IsAuthenticated
|
||||
|
||||
from lostplaces_app.views.base_views import (
|
||||
PlaceAssetCreateView,
|
||||
@ -19,7 +20,7 @@ class SignUpView(SuccessMessageMixin, CreateView):
|
||||
template_name = 'signup.html'
|
||||
success_message = 'User created.'
|
||||
|
||||
class HomeView(View):
|
||||
class HomeView(IsAuthenticated, View):
|
||||
def get(self, request, *args, **kwargs):
|
||||
place_list = Place.objects.all().order_by('-submitted_when')[:10]
|
||||
place_map_center = Place.average_latlon(place_list)
|
||||
@ -29,6 +30,13 @@ class HomeView(View):
|
||||
}
|
||||
return render(request, 'home.html', context)
|
||||
|
||||
def handle_no_permission(self):
|
||||
place_list = Place.objects.all().order_by('-submitted_when')[:10]
|
||||
context = {
|
||||
'place_list': place_list
|
||||
}
|
||||
return render(self.request, 'home_unauth.html', context)
|
||||
|
||||
class PhotoAlbumCreateView(PlaceAssetCreateView):
|
||||
model = PhotoAlbum
|
||||
fields = ['url', 'label']
|
||||
|
Loading…
Reference in New Issue
Block a user