Merge branch 'main' into question_invite_correct

This commit is contained in:
Corentin Feys
2022-03-13 23:44:20 +01:00
committed by GitHub
41 changed files with 716 additions and 489 deletions

View File

@ -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(),
}

View File

@ -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)