mirror of
https://github.com/sissbruecker/linkding.git
synced 2025-08-07 02:48:27 +02:00

* Make shared view public, add user profile fallback * Allow unauthenticated access to shared bookmarks API * Link shared bookmarks in unauthenticated layout * Add public sharing setting * Only show shared bookmarks link if there are publicly shared bookmarks * Disable public sharing if sharing is disabled * Show specific helper text when public sharing is enabled * Fix tests * Add more tests * Improve setting description
26 lines
716 B
Python
26 lines
716 B
Python
from bookmarks import queries
|
|
from bookmarks.models import Toast
|
|
|
|
|
|
def toasts(request):
|
|
user = request.user
|
|
toast_messages = Toast.objects.filter(owner=user, acknowledged=False) if user.is_authenticated else []
|
|
has_toasts = len(toast_messages) > 0
|
|
|
|
return {
|
|
'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:
|
|
query_set = queries.query_shared_bookmarks(None, request.user_profile, '', True)
|
|
has_public_shares = query_set.count() > 0
|
|
return {
|
|
'has_public_shares': has_public_shares,
|
|
}
|
|
|
|
return {}
|