Implement add bookmark route

This commit is contained in:
Sascha Ißbrücker
2019-06-28 19:37:41 +02:00
parent e2a834a56c
commit c653206dd3
11 changed files with 100 additions and 13 deletions

View File

@@ -0,0 +1,21 @@
from django.contrib.auth.models import User
from django.utils import timezone
from bookmarks.models import Bookmark
def create_bookmark(bookmark: Bookmark, current_user: User):
# Update website info
_update_website_metadata(bookmark)
# Set currently logged in user as owner
bookmark.owner = current_user
# Set dates
bookmark.date_added = timezone.now()
bookmark.save()
def _update_website_metadata(bookmark: Bookmark):
# TODO: Load website metadata
bookmark.website_title = 'Title from website'
bookmark.website_description = 'Description from website'
pass