mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-23 08:36:32 +00:00
Merge branch 'main' into cache-fix
This commit is contained in:
commit
aaccab6dce
4 changed files with 31 additions and 24 deletions
|
@ -36,22 +36,19 @@ def get_next_shelf(current_shelf):
|
|||
def active_shelf(context, book):
|
||||
"""check what shelf a user has a book on, if any"""
|
||||
user = context["request"].user
|
||||
return (
|
||||
cache.get_or_set(
|
||||
f"active_shelf-{user.id}-{book.id}",
|
||||
lambda u, b: (
|
||||
models.ShelfBook.objects.filter(
|
||||
shelf__user=u,
|
||||
book__parent_work__editions=b,
|
||||
).first()
|
||||
or False
|
||||
),
|
||||
user,
|
||||
book,
|
||||
timeout=15552000,
|
||||
)
|
||||
or {"book": book}
|
||||
)
|
||||
return cache.get_or_set(
|
||||
f"active_shelf-{user.id}-{book.id}",
|
||||
lambda u, b: (
|
||||
models.ShelfBook.objects.filter(
|
||||
shelf__user=u,
|
||||
book__parent_work__editions=b,
|
||||
).first()
|
||||
or False
|
||||
),
|
||||
user,
|
||||
book,
|
||||
timeout=15552000,
|
||||
) or {"book": book}
|
||||
|
||||
|
||||
@register.simple_tag(takes_context=False)
|
||||
|
|
|
@ -430,7 +430,7 @@ class ModelFields(TestCase):
|
|||
output = instance.field_to_activity(user.avatar)
|
||||
self.assertIsNotNone(
|
||||
re.match(
|
||||
fr"https:\/\/{DOMAIN}\/.*\.jpg",
|
||||
rf"https:\/\/{DOMAIN}\/.*\.jpg",
|
||||
output.url,
|
||||
)
|
||||
)
|
||||
|
|
|
@ -34,9 +34,11 @@ urlpatterns = [
|
|||
TemplateView.as_view(template_name="robots.txt", content_type="text/plain"),
|
||||
),
|
||||
# federation endpoints
|
||||
re_path(r"^inbox/?$", views.Inbox.as_view()),
|
||||
re_path(rf"{LOCAL_USER_PATH}/inbox/?$", views.Inbox.as_view()),
|
||||
re_path(rf"{LOCAL_USER_PATH}/outbox/?$", views.Outbox.as_view()),
|
||||
re_path(r"^inbox/?$", views.Inbox.as_view(), name="inbox"),
|
||||
re_path(rf"{LOCAL_USER_PATH}/inbox/?$", views.Inbox.as_view(), name="user_inbox"),
|
||||
re_path(
|
||||
rf"{LOCAL_USER_PATH}/outbox/?$", views.Outbox.as_view(), name="user_outbox"
|
||||
),
|
||||
re_path(r"^\.well-known/webfinger/?$", views.webfinger),
|
||||
re_path(r"^\.well-known/nodeinfo/?$", views.nodeinfo_pointer),
|
||||
re_path(r"^\.well-known/host-meta/?$", views.host_meta),
|
||||
|
@ -46,9 +48,15 @@ urlpatterns = [
|
|||
re_path(r"^opensearch.xml$", views.opensearch, name="opensearch"),
|
||||
re_path(r"^ostatus_subscribe/?$", views.ostatus_follow_request),
|
||||
# polling updates
|
||||
re_path("^api/updates/notifications/?$", views.get_notification_count),
|
||||
re_path(
|
||||
"^api/updates/stream/(?P<stream>[a-z]+)/?$", views.get_unread_status_string
|
||||
"^api/updates/notifications/?$",
|
||||
views.get_notification_count,
|
||||
name="notification-updates",
|
||||
),
|
||||
re_path(
|
||||
"^api/updates/stream/(?P<stream>[a-z]+)/?$",
|
||||
views.get_unread_status_string,
|
||||
name="stream-updates",
|
||||
),
|
||||
# authentication
|
||||
re_path(r"^login/?$", views.Login.as_view(), name="login"),
|
||||
|
@ -149,7 +157,9 @@ urlpatterns = [
|
|||
re_path(
|
||||
r"^invite-request/?$", views.InviteRequest.as_view(), name="invite-request"
|
||||
),
|
||||
re_path(r"^invite/(?P<code>[A-Za-z0-9]+)/?$", views.Invite.as_view()),
|
||||
re_path(
|
||||
r"^invite/(?P<code>[A-Za-z0-9]+)/?$", views.Invite.as_view(), name="invite"
|
||||
),
|
||||
re_path(
|
||||
r"^settings/email-blocklist/?$",
|
||||
views.EmailBlocklist.as_view(),
|
||||
|
|
|
@ -20,7 +20,7 @@ django-storages==1.11.1
|
|||
django-redis==5.2.0
|
||||
|
||||
# Dev
|
||||
black==21.4b0
|
||||
black==21.4b2
|
||||
pytest-django==4.1.0
|
||||
pytest==6.1.2
|
||||
pytest-cov==2.10.1
|
||||
|
|
Loading…
Reference in a new issue