linkding/bookmarks/context_processors.py

37 lines
902 B
Python
Raw Normal View History

from bookmarks import queries
from bookmarks.models import BookmarkSearch, Toast
from bookmarks import utils
def toasts(request):
user = request.user
2024-01-27 10:29:16 +00:00
toast_messages = (
Toast.objects.filter(owner=user, acknowledged=False)
if user.is_authenticated
else []
)
has_toasts = len(toast_messages) > 0
return {
2024-01-27 10:29:16 +00:00
"has_toasts": has_toasts,
"toast_messages": toast_messages,
}
def public_shares(request):
# Only check for public shares for anonymous users
if not request.user.is_authenticated:
2024-01-27 10:29:16 +00:00
query_set = queries.query_shared_bookmarks(
None, request.user_profile, BookmarkSearch(), True
)
has_public_shares = query_set.count() > 0
return {
2024-01-27 10:29:16 +00:00
"has_public_shares": has_public_shares,
}
return {}
def app_version(request):
2024-01-27 10:29:16 +00:00
return {"app_version": utils.app_version}