mirror of
https://github.com/sissbruecker/linkding.git
synced 2025-08-08 19:28:29 +02:00
#23 Prevent bookmark duplicates
* Show hint if URL is already bookmarked * Remove hint if URL belongs to edited bookmark * Fix query param encoding * Update bookmark instead of duplicating it Co-authored-by: Sascha Ißbrücker <sissbruecker@lyska.io>
This commit is contained in:
@@ -7,6 +7,14 @@ from bookmarks.services.website_loader import load_website_metadata
|
||||
|
||||
|
||||
def create_bookmark(form: BookmarkForm, current_user: User):
|
||||
# If URL is already bookmarked, then update it
|
||||
existing_bookmark = Bookmark.objects.filter(owner=current_user, url=form.data['url']).first()
|
||||
|
||||
if existing_bookmark is not None:
|
||||
update_form = BookmarkForm(data=form.data, instance=existing_bookmark)
|
||||
update_bookmark(update_form, current_user)
|
||||
return
|
||||
|
||||
bookmark = form.save(commit=False)
|
||||
# Update website info
|
||||
_update_website_metadata(bookmark)
|
||||
|
Reference in New Issue
Block a user