#64 place mode and filtering of place modes in list views

This commit is contained in:
Leonhard Strohmidel
2022-09-24 12:10:19 +02:00
parent 49301afe51
commit c9d83dfc2c
7 changed files with 92 additions and 15 deletions

View File

@@ -138,4 +138,10 @@ class LevelCapPlaceListView(ListView):
model = Place
def get_queryset(self):
return self.request.user.explorer.get_places_eligible_to_see()
return self.request.user.explorer.get_place_list_to_display()
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['place_list'] = context.pop('object_list')
return context

View File

@@ -13,7 +13,7 @@ from django.utils.translation import gettext as _
from lostplaces.forms import SignupVoucherForm, TagSubmitForm
from lostplaces.models import Place, PhotoAlbum
from lostplaces.views.base_views import IsAuthenticatedMixin
from lostplaces.views.base_views import IsAuthenticatedMixin, LevelCapPlaceListView
from lostplaces.common import redirect_referer_or
from lostplaces.views.base_views import (
@@ -29,17 +29,19 @@ class SignUpView(SuccessMessageMixin, CreateView):
template_name = 'signup.html'
success_message = _('User created')
class HomeView(IsAuthenticatedMixin, View):
def get(self, request, *args, **kwargs):
place_list = request.user.explorer.get_places_eligible_to_see()
context = {
'place_list': place_list,
'mapping_config': {
'all_points': place_list,
'map_center': Place.average_latlon(place_list)
}
class HomeView(IsAuthenticatedMixin, LevelCapPlaceListView, View):
template_name = 'home.html'
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
place_list = context['place_list']
context['mapping_config'] = {
'all_points': place_list,
'map_center': Place.average_latlon(place_list)
}
return render(request, 'home.html', context)
return context
def handle_no_permission(self):
place_list = Place.objects.filter(level=1)[:5]