moviewyrm/bookwyrm/views/landing.py

42 lines
1.1 KiB
Python
Raw Normal View History

2021-03-08 16:49:10 +00:00
""" non-interactive pages """
2021-01-12 18:44:17 +00:00
from django.template.response import TemplateResponse
from django.views import View
2021-03-21 23:37:52 +00:00
from bookwyrm import forms
2021-01-29 18:25:31 +00:00
from .feed import Feed
2021-03-21 02:14:41 +00:00
from . import helpers
2021-01-12 18:44:17 +00:00
# pylint: disable= no-self-use
class About(View):
2021-04-26 16:15:42 +00:00
"""create invites"""
2021-03-08 16:49:10 +00:00
2021-01-12 18:44:17 +00:00
def get(self, request):
2021-04-26 16:15:42 +00:00
"""more information about the instance"""
2021-03-08 16:49:10 +00:00
return TemplateResponse(request, "discover/about.html")
2021-01-12 18:44:17 +00:00
class Home(View):
2021-04-26 16:15:42 +00:00
"""discover page or home feed depending on auth"""
2021-03-08 16:49:10 +00:00
2021-01-12 18:44:17 +00:00
def get(self, request):
2021-04-26 16:15:42 +00:00
"""this is the same as the feed on the home tab"""
2021-01-12 18:44:17 +00:00
if request.user.is_authenticated:
feed_view = Feed.as_view()
2021-03-08 16:49:10 +00:00
return feed_view(request, "home")
2021-01-12 18:44:17 +00:00
discover_view = Discover.as_view()
return discover_view(request)
2021-03-08 16:49:10 +00:00
2021-01-12 18:44:17 +00:00
class Discover(View):
2021-04-26 16:15:42 +00:00
"""preview of recently reviewed books"""
2021-03-08 16:49:10 +00:00
2021-01-12 18:44:17 +00:00
def get(self, request):
2021-04-26 16:15:42 +00:00
"""tiled book activity page"""
2021-01-12 18:44:17 +00:00
data = {
2021-03-08 16:49:10 +00:00
"register_form": forms.RegisterForm(),
2021-03-21 02:14:41 +00:00
"request_form": forms.InviteRequestForm(),
"books": helpers.get_discover_books(),
2021-01-12 18:44:17 +00:00
}
2021-03-08 16:49:10 +00:00
return TemplateResponse(request, "discover/discover.html", data)