1
0
mirror of https://github.com/aquatix/digimarks.git synced 2025-12-07 02:35:10 +01:00

Check whether a bookmark (url) already existed, redirect with a warning

This commit is contained in:
2016-07-21 16:00:05 +02:00
parent 5693f5d676
commit c7acf09cf9
2 changed files with 19 additions and 5 deletions

View File

@@ -219,8 +219,9 @@ def editbookmark(userkey, urlhash):
""" Bookmark edit form """
# bookmark = getbyurlhash()
bookmark = Bookmark.get(Bookmark.url_hash == urlhash, Bookmark.userkey == userkey)
message = request.args.get('message')
print bookmark.url
return render_template('edit.html', action='Edit bookmark', userkey=userkey, bookmark=bookmark)
return render_template('edit.html', action='Edit bookmark', userkey=userkey, bookmark=bookmark, message=message)
@app.route('/<userkey>/add')
@@ -249,10 +250,12 @@ def addingbookmark(userkey):
if url:
#bookmark = Bookmark(url=url, title=title, starred=starred, userkey=userkey)
bookmark, created = Bookmark.get_or_create(url=url, userkey=userkey)
print created
if created:
bookmark.title = title
bookmark.starred = starred
if not created:
return redirect(url_for('editbookmark', userkey=userkey, urlhash=bookmark.url_hash, message='Existing bookmark, did not overwrite with new values'))
# Newly created, set properties
bookmark.title = title
bookmark.starred = starred
bookmark.set_tags(tags)
bookmark.set_hash()
#bookmark.fetch_image()