2023-08-14 22:20:52 +00:00
|
|
|
from bookmarks import queries
|
2023-09-01 20:48:21 +00:00
|
|
|
from bookmarks.models import BookmarkSearch, Toast
|
2023-08-23 08:54:25 +00:00
|
|
|
from bookmarks import utils
|
2022-05-14 07:46:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
def toasts(request):
|
2023-08-14 22:20:52 +00:00
|
|
|
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 []
|
|
|
|
)
|
2022-05-14 07:46:51 +00:00
|
|
|
has_toasts = len(toast_messages) > 0
|
|
|
|
|
|
|
|
return {
|
2024-01-27 10:29:16 +00:00
|
|
|
"has_toasts": has_toasts,
|
|
|
|
"toast_messages": toast_messages,
|
2022-05-14 07:46:51 +00:00
|
|
|
}
|
2023-08-14 22:20:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
)
|
2023-08-14 22:20:52 +00:00
|
|
|
has_public_shares = query_set.count() > 0
|
|
|
|
return {
|
2024-01-27 10:29:16 +00:00
|
|
|
"has_public_shares": has_public_shares,
|
2023-08-14 22:20:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return {}
|
2023-08-23 08:54:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
def app_version(request):
|
2024-01-27 10:29:16 +00:00
|
|
|
return {"app_version": utils.app_version}
|