Merge branch 'main' into partially-read-shelf
This commit is contained in:
commit
ee414598bf
65 changed files with 2385 additions and 1859 deletions
|
@ -1,7 +1,5 @@
|
|||
""" manage themes """
|
||||
from django.contrib.auth.decorators import login_required, permission_required
|
||||
from django.contrib.staticfiles.utils import get_files
|
||||
from django.contrib.staticfiles.storage import StaticFilesStorage
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
from django.template.response import TemplateResponse
|
||||
from django.utils.decorators import method_decorator
|
||||
|
@ -41,11 +39,8 @@ class Themes(View):
|
|||
|
||||
def get_view_data():
|
||||
"""data for view"""
|
||||
choices = list(get_files(StaticFilesStorage(), location="css/themes"))
|
||||
current = models.Theme.objects.values_list("path", flat=True)
|
||||
return {
|
||||
"themes": models.Theme.objects.all(),
|
||||
"choices": [c for c in choices if c not in current and c[-5:] == ".scss"],
|
||||
"theme_form": forms.ThemeForm(),
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ from bookwyrm.settings import PAGE_LENGTH
|
|||
class UserAdminList(View):
|
||||
"""admin view of users on this server"""
|
||||
|
||||
def get(self, request):
|
||||
def get(self, request, status="local"):
|
||||
"""list of users"""
|
||||
filters = {}
|
||||
server = request.GET.get("server")
|
||||
|
@ -37,6 +37,8 @@ class UserAdminList(View):
|
|||
if email:
|
||||
filters["email__endswith"] = email
|
||||
|
||||
filters["local"] = status == "local"
|
||||
|
||||
users = models.User.objects.filter(**filters)
|
||||
|
||||
sort = request.GET.get("sort", "-created_date")
|
||||
|
@ -56,6 +58,7 @@ class UserAdminList(View):
|
|||
"users": paginated.get_page(request.GET.get("page")),
|
||||
"sort": sort,
|
||||
"server": server,
|
||||
"status": status,
|
||||
}
|
||||
return TemplateResponse(request, "settings/users/user_admin.html", data)
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ from django.views.decorators.http import require_POST
|
|||
|
||||
from bookwyrm import forms, models
|
||||
from bookwyrm.activitypub import ActivitypubResponse
|
||||
from bookwyrm.connectors import connector_manager
|
||||
from bookwyrm.connectors import connector_manager, ConnectorException
|
||||
from bookwyrm.connectors.abstract_connector import get_image
|
||||
from bookwyrm.settings import PAGE_LENGTH
|
||||
from bookwyrm.views.helpers import is_api_request
|
||||
|
@ -22,7 +22,7 @@ from bookwyrm.views.helpers import is_api_request
|
|||
class Book(View):
|
||||
"""a book! this is the stuff"""
|
||||
|
||||
def get(self, request, book_id, user_statuses=False):
|
||||
def get(self, request, book_id, user_statuses=False, update_error=False):
|
||||
"""info about a book"""
|
||||
if is_api_request(request):
|
||||
book = get_object_or_404(
|
||||
|
@ -80,6 +80,7 @@ class Book(View):
|
|||
else None,
|
||||
"rating": reviews.aggregate(Avg("rating"))["rating__avg"],
|
||||
"lists": lists,
|
||||
"update_error": update_error,
|
||||
}
|
||||
|
||||
if request.user.is_authenticated:
|
||||
|
@ -191,6 +192,10 @@ def update_book_from_remote(request, book_id, connector_identifier):
|
|||
)
|
||||
book = get_object_or_404(models.Book.objects.select_subclasses(), id=book_id)
|
||||
|
||||
connector.update_book_from_remote(book)
|
||||
try:
|
||||
connector.update_book_from_remote(book)
|
||||
except ConnectorException:
|
||||
# the remote source isn't available or doesn't know this book
|
||||
return Book().get(request, book_id, update_error=True)
|
||||
|
||||
return redirect("book", book.id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue