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
|
|
|
|
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 {
|
|
|
|
'has_toasts': has_toasts,
|
|
|
|
'toast_messages': toast_messages,
|
|
|
|
}
|
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:
|
2023-09-01 20:48:21 +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 {
|
|
|
|
'has_public_shares': has_public_shares,
|
|
|
|
}
|
|
|
|
|
|
|
|
return {}
|
2023-08-23 08:54:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
def app_version(request):
|
|
|
|
return {
|
|
|
|
'app_version': utils.app_version
|
|
|
|
}
|