Updates code for linter
This commit is contained in:
parent
20f74ba02b
commit
4479864008
21 changed files with 71 additions and 61 deletions
|
@ -38,7 +38,7 @@ def is_api_request(request):
|
|||
def is_bookwyrm_request(request):
|
||||
"""check if the request is coming from another bookwyrm instance"""
|
||||
user_agent = request.headers.get("User-Agent")
|
||||
if user_agent is None or re.search(regex.bookwyrm_user_agent, user_agent) is None:
|
||||
if user_agent is None or re.search(regex.BOOKWYRM_USER_AGENT, user_agent) is None:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ from bookwyrm.utils import regex
|
|||
class Inbox(View):
|
||||
"""requests sent by outside servers"""
|
||||
|
||||
# pylint: disable=too-many-return-statements
|
||||
def post(self, request, username=None):
|
||||
"""only works as POST request"""
|
||||
# first check if this server is on our shitlist
|
||||
|
@ -70,7 +71,7 @@ def is_blocked_user_agent(request):
|
|||
user_agent = request.headers.get("User-Agent")
|
||||
if not user_agent:
|
||||
return False
|
||||
url = re.search(r"https?://{:s}/?".format(regex.domain), user_agent)
|
||||
url = re.search(r"https?://{:s}/?".format(regex.DOMAIN), user_agent)
|
||||
if not url:
|
||||
return False
|
||||
url = url.group()
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
""" isbn search view """
|
||||
from django.http import HttpResponseNotFound
|
||||
from django.http import JsonResponse
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
from django.template.response import TemplateResponse
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.views import View
|
||||
from django.views.decorators.http import require_POST
|
||||
|
||||
from bookwyrm import forms, models
|
||||
from bookwyrm.connectors import connector_manager
|
||||
from .helpers import is_api_request
|
||||
|
||||
|
@ -23,7 +18,6 @@ class Isbn(View):
|
|||
return JsonResponse([r.json() for r in book_results], safe=False)
|
||||
|
||||
data = {
|
||||
"title": "ISBN Search Results",
|
||||
"results": book_results,
|
||||
"query": isbn,
|
||||
}
|
||||
|
|
|
@ -314,8 +314,7 @@ def set_book_position(request, list_item_id):
|
|||
Max("order")
|
||||
)["order__max"]
|
||||
|
||||
if int_position > order_max:
|
||||
int_position = order_max
|
||||
int_position = min(int_position, order_max)
|
||||
|
||||
if request.user not in (book_list.user, list_item.user):
|
||||
return HttpResponseNotFound()
|
||||
|
|
|
@ -10,7 +10,7 @@ class RssFeed(Feed):
|
|||
description_template = "rss/content.html"
|
||||
title_template = "rss/title.html"
|
||||
|
||||
def get_object(self, request, username):
|
||||
def get_object(self, request, username): # pylint: disable=arguments-differ
|
||||
"""the user who's posts get serialized"""
|
||||
return get_user_from_username(request.user, username)
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ def user_search(query, viewer, *_):
|
|||
|
||||
# use webfinger for mastodon style account@domain.com username to load the user if
|
||||
# they don't exist locally (handle_remote_webfinger will check the db)
|
||||
if re.match(regex.full_username, query):
|
||||
if re.match(regex.FULL_USERNAME, query):
|
||||
handle_remote_webfinger(query)
|
||||
|
||||
return (
|
||||
|
|
|
@ -17,7 +17,7 @@ from bookwyrm import forms, models
|
|||
from bookwyrm.activitypub import ActivitypubResponse
|
||||
from bookwyrm.settings import PAGE_LENGTH
|
||||
from .helpers import is_api_request, get_edition, get_user_from_username
|
||||
from .helpers import handle_reading_status, privacy_filter
|
||||
from .helpers import privacy_filter
|
||||
|
||||
|
||||
# pylint: disable=no-self-use
|
||||
|
|
|
@ -133,7 +133,7 @@ def find_mentions(content):
|
|||
"""detect @mentions in raw status content"""
|
||||
if not content:
|
||||
return
|
||||
for match in re.finditer(regex.strict_username, content):
|
||||
for match in re.finditer(rhandle_reading_status, egex.STRICT_USERNAME, content):
|
||||
username = match.group().strip().split("@")[1:]
|
||||
if len(username) == 1:
|
||||
# this looks like a local user (@user), fill in the domain
|
||||
|
@ -150,7 +150,7 @@ def find_mentions(content):
|
|||
def format_links(content):
|
||||
"""detect and format links"""
|
||||
return re.sub(
|
||||
r'([^(href=")]|^|\()(https?:\/\/(%s([\w\.\-_\/+&\?=:;,])*))' % regex.domain,
|
||||
r'([^(href=")]|^|\()(https?:\/\/(%s([\w\.\-_\/+&\?=:;,])*))' % regex.DOMAIN,
|
||||
r'\g<1><a href="\g<2>">\g<3></a>',
|
||||
content,
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue