Runs black

This commit is contained in:
Mouse Reeve
2021-03-08 08:49:10 -08:00
parent a07f955781
commit 70296e760b
198 changed files with 10239 additions and 8572 deletions

View File

@ -1,4 +1,4 @@
''' the good people stuff! the authors! '''
""" the good people stuff! the authors! """
from django.contrib.auth.decorators import login_required, permission_required
from django.db.models import Q
from django.shortcuts import get_object_or_404, redirect
@ -13,49 +13,46 @@ from .helpers import is_api_request
# pylint: disable= no-self-use
class Author(View):
''' this person wrote a book '''
""" this person wrote a book """
def get(self, request, author_id):
''' landing page for an author '''
""" landing page for an author """
author = get_object_or_404(models.Author, id=author_id)
if is_api_request(request):
return ActivitypubResponse(author.to_activity())
books = models.Work.objects.filter(
Q(authors=author) | Q(editions__authors=author)).distinct()
Q(authors=author) | Q(editions__authors=author)
).distinct()
data = {
'author': author,
'books': [b.get_default_edition() for b in books],
"author": author,
"books": [b.get_default_edition() for b in books],
}
return TemplateResponse(request, 'author.html', data)
return TemplateResponse(request, "author.html", data)
@method_decorator(login_required, name='dispatch')
@method_decorator(login_required, name="dispatch")
@method_decorator(
permission_required('bookwyrm.edit_book', raise_exception=True),
name='dispatch')
permission_required("bookwyrm.edit_book", raise_exception=True), name="dispatch"
)
class EditAuthor(View):
''' edit author info '''
""" edit author info """
def get(self, request, author_id):
''' info about a book '''
""" info about a book """
author = get_object_or_404(models.Author, id=author_id)
data = {
'author': author,
'form': forms.AuthorForm(instance=author)
}
return TemplateResponse(request, 'edit_author.html', data)
data = {"author": author, "form": forms.AuthorForm(instance=author)}
return TemplateResponse(request, "edit_author.html", data)
def post(self, request, author_id):
''' edit a author cool '''
""" edit a author cool """
author = get_object_or_404(models.Author, id=author_id)
form = forms.AuthorForm(request.POST, request.FILES, instance=author)
if not form.is_valid():
data = {
'author': author,
'form': form
}
return TemplateResponse(request, 'edit_author.html', data)
data = {"author": author, "form": form}
return TemplateResponse(request, "edit_author.html", data)
author = form.save()
return redirect('/author/%s' % author.id)
return redirect("/author/%s" % author.id)