Fixes #1777 Caching the Landing view also caches the registration form, including the CSRF value. This moves the caching into the recently reviewed books landing template which is presumably what we're trying to cache here, instead of caching the whole view. NOTE: this fixes the problem with registration, I haven't done enough testing to be sure it actually still caches the recent reviews data.
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
""" non-interactive pages """
|
|
from django.template.response import TemplateResponse
|
|
from django.views import View
|
|
from django.utils.decorators import method_decorator
|
|
from django.views.decorators.cache import cache_page
|
|
|
|
from bookwyrm import forms
|
|
from bookwyrm.views import helpers
|
|
from bookwyrm.views.feed import Feed
|
|
|
|
|
|
# pylint: disable= no-self-use
|
|
class About(View):
|
|
"""create invites"""
|
|
|
|
def get(self, request):
|
|
"""more information about the instance"""
|
|
return TemplateResponse(request, "landing/about.html")
|
|
|
|
|
|
class Home(View):
|
|
"""landing page or home feed depending on auth"""
|
|
|
|
def get(self, request):
|
|
"""this is the same as the feed on the home tab"""
|
|
if request.user.is_authenticated:
|
|
feed_view = Feed.as_view()
|
|
return feed_view(request, "home")
|
|
landing_view = Landing.as_view()
|
|
return landing_view(request)
|
|
|
|
|
|
class Landing(View):
|
|
"""preview of recently reviewed books"""
|
|
|
|
def get(self, request):
|
|
"""tiled book activity page"""
|
|
data = {
|
|
"register_form": forms.RegisterForm(),
|
|
"request_form": forms.InviteRequestForm(),
|
|
"books": helpers.get_landing_books(),
|
|
}
|
|
return TemplateResponse(request, "landing/landing.html", data)
|