""" book list views"""
from django.contrib.auth.decorators import login_required
from django.core.paginator import Paginator
from django.shortcuts import redirect
from django.template.response import TemplateResponse
from django.utils.decorators import method_decorator
from django.views import View

from bookwyrm import forms, models
from bookwyrm.lists_stream import ListsStream
from bookwyrm.views.helpers import get_user_from_username


# pylint: disable=no-self-use
class Lists(View):
    """book list page"""

    def get(self, request):
        """display a book list"""
        if request.user.is_authenticated:
            lists = ListsStream().get_list_stream(request.user)
        else:
            lists = models.List.objects.filter(privacy="public")
        paginated = Paginator(lists, 12)
        data = {
            "lists": paginated.get_page(request.GET.get("page")),
            "list_form": forms.ListForm(),
            "path": "/list",
        }
        return TemplateResponse(request, "lists/lists.html", data)

    @method_decorator(login_required, name="dispatch")
    # pylint: disable=unused-argument
    def post(self, request):
        """create a book_list"""
        form = forms.ListForm(request.POST)
        if not form.is_valid():
            return redirect("lists")
        book_list = form.save(request, commit=False)

        # list should not have a group if it is not group curated
        if not book_list.curation == "group":
            book_list.group = None
        book_list.save()

        return redirect(book_list.local_path)


@method_decorator(login_required, name="dispatch")
class SavedLists(View):
    """saved book list page"""

    def get(self, request):
        """display book lists"""
        # hide lists with no approved books
        lists = request.user.saved_lists.order_by("-updated_date")

        paginated = Paginator(lists, 12)
        data = {
            "lists": paginated.get_page(request.GET.get("page")),
            "list_form": forms.ListForm(),
            "path": "/list",
        }
        return TemplateResponse(request, "lists/lists.html", data)


@method_decorator(login_required, name="dispatch")
class UserLists(View):
    """a user's book list page"""

    def get(self, request, username):
        """display a book list"""
        user = get_user_from_username(request.user, username)
        lists = models.List.privacy_filter(request.user).filter(user=user)
        paginated = Paginator(lists, 12)

        data = {
            "user": user,
            "is_self": request.user.id == user.id,
            "lists": paginated.get_page(request.GET.get("page")),
            "list_form": forms.ListForm(),
            "path": user.local_path + "/lists",
        }
        return TemplateResponse(request, "user/lists.html", data)

bookwyrm/views/list/lists.py
""" book list views"""
from django.contrib.auth.decorators import login_required
from django.core.paginator import Paginator
from django.shortcuts import redirect
from django.template.response import TemplateResponse
from django.utils.decorators import method_decorator
from django.views import View

from bookwyrm import forms, models
from bookwyrm.lists_stream import ListsStream
from bookwyrm.views.helpers import get_user_from_username


# pylint: disable=no-self-use
class Lists(View):
    """book list page"""

    def get(self, request):
        """display a book list"""
        if request.user.is_authenticated:
            lists = ListsStream().get_list_stream(request.user)
        else:
            lists = models.List.objects.filter(privacy="public")
        paginated = Paginator(lists, 12)
        data = {
            "lists": paginated.get_page(request.GET.get("page")),
            "list_form": forms.ListForm(),
            "path": "/list",
        }
        return TemplateResponse(request, "lists/lists.html", data)

    @method_decorator(login_required, name="dispatch")
    # pylint: disable=unused-argument
    def post(self, request):
        """create a book_list"""
        form = forms.ListForm(request.POST)
        if not form.is_valid():
            return redirect("lists")
        book_list = form.save(request, commit=False)

        # list should not have a group if it is not group curated
        if not book_list.curation == "group":
            book_list.group = None
        book_list.save()

        return redirect(book_list.local_path)


@method_decorator(login_required, name="dispatch")
class SavedLists(View):
    """saved book list page"""

    def get(self, request):
        """display book lists"""
        # hide lists with no approved books
        lists = request.user.saved_lists.order_by("-updated_date")

        paginated = Paginator(lists, 12)
        data = {
            "lists": paginated.get_page(request.GET.get("page")),
            "list_form": forms.ListForm(),
            "path": "/list/saved",
        }
        return TemplateResponse(request, "lists/lists.html", data)


@method_decorator(login_required, name="dispatch")
class UserLists(View):
    """a user's book list page"""

    def get(self, request, username):
        """display a book list"""
        user = get_user_from_username(request.user, username)
        lists = models.List.privacy_filter(request.user).filter(user=user)
        paginated = Paginator(lists, 12)

        data = {
            "user": user,
            "is_self": request.user.id == user.id,
            "lists": paginated.get_page(request.GET.get("page")),
            "list_form": forms.ListForm(),
            "path": user.local_path + "/lists",
        }
        return TemplateResponse(request, "user/lists.html", data)

bookwyrm/views/list/lists.py
diff --git a/bookwyrm/views/list/lists.py b/bookwyrm/views/list/lists.py
index 2514fad58b..52b65357a1 100644
--- a/bookwyrm/views/list/lists.py
+++ b/bookwyrm/views/list/lists.py
@@ -59,7 +59,7 @@ def get(self, request):
         data = {
             "lists": paginated.get_page(request.GET.get("page")),
             "list_form": forms.ListForm(),
-            "path": "/list",
+            "path": "/list/saved",
         }
         return TemplateResponse(request, "lists/lists.html", data)
 

Saved lists pagination is broken
**Describe the bug**
Trying to move through pages of saved lists is broken. Instead, one moves back to all lists.

**To Reproduce**
Steps to reproduce the behavior:
1. Save enough lists to have at least two pages
2. Go to [`Lists -> Saved Lists`](https://bookwyrm.social/list/saved)
3. Click on `Next`
4. Wonder why the lists shown are not the ones you saved
5. Realize you're back on `All Lists`

**Expected behavior**
One should be able to paginate through saved lists

**Instance**
[bookwyrm.social](https://bookwyrm.social/)

**Additional comments**
I'm trying to dig through the code a bit, but I don't have time to setup dev environment and populate local dbs and whatever needs to be done. It might just be that `path` needs to be changed to `/list/saved` [here](https://github.com/bookwyrm-social/bookwyrm/blob/6667178703b93d0d1874f1fd547e97c12a2ec144/bookwyrm/views/list/lists.py#L62)? But idk, this isn't a stack I'm very intimate with 🤷

