2021-01-12 18:44:17 +00:00
|
|
|
''' non-interactive pages '''
|
2021-02-24 19:59:21 +00:00
|
|
|
from django.db.models import Max
|
2021-01-12 18:44:17 +00:00
|
|
|
from django.template.response import TemplateResponse
|
|
|
|
from django.views import View
|
|
|
|
|
|
|
|
from bookwyrm import forms, models
|
2021-01-29 18:25:31 +00:00
|
|
|
from .feed import Feed
|
2021-01-12 18:44:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
# pylint: disable= no-self-use
|
|
|
|
class About(View):
|
|
|
|
''' create invites '''
|
|
|
|
def get(self, request):
|
|
|
|
''' more information about the instance '''
|
|
|
|
data = {
|
|
|
|
'title': 'About',
|
|
|
|
}
|
2021-02-24 03:58:04 +00:00
|
|
|
return TemplateResponse(request, 'discover/about.html', data)
|
2021-01-12 18:44:17 +00:00
|
|
|
|
|
|
|
class Home(View):
|
|
|
|
''' discover 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')
|
|
|
|
discover_view = Discover.as_view()
|
|
|
|
return discover_view(request)
|
|
|
|
|
|
|
|
class Discover(View):
|
|
|
|
''' preview of recently reviewed books '''
|
|
|
|
def get(self, request):
|
|
|
|
''' tiled book activity page '''
|
|
|
|
books = models.Edition.objects.filter(
|
|
|
|
review__published_date__isnull=False,
|
2021-02-24 19:59:21 +00:00
|
|
|
review__deleted=False,
|
2021-01-12 18:44:17 +00:00
|
|
|
review__user__local=True,
|
|
|
|
review__privacy__in=['public', 'unlisted'],
|
|
|
|
).exclude(
|
|
|
|
cover__exact=''
|
|
|
|
).annotate(
|
|
|
|
Max('review__published_date')
|
|
|
|
).order_by('-review__published_date__max')[:6]
|
|
|
|
|
|
|
|
data = {
|
|
|
|
'title': 'Discover',
|
|
|
|
'register_form': forms.RegisterForm(),
|
|
|
|
'books': list(set(books)),
|
|
|
|
}
|
2021-02-23 22:06:08 +00:00
|
|
|
return TemplateResponse(request, 'discover/discover.html', data)
|