mirror of
https://github.com/aquatix/digimarks.git
synced 2025-12-07 01:25:11 +01:00
Check whether a bookmark (url) already existed, redirect with a warning
This commit is contained in:
13
digimarks.py
13
digimarks.py
@@ -219,8 +219,9 @@ def editbookmark(userkey, urlhash):
|
|||||||
""" Bookmark edit form """
|
""" Bookmark edit form """
|
||||||
# bookmark = getbyurlhash()
|
# bookmark = getbyurlhash()
|
||||||
bookmark = Bookmark.get(Bookmark.url_hash == urlhash, Bookmark.userkey == userkey)
|
bookmark = Bookmark.get(Bookmark.url_hash == urlhash, Bookmark.userkey == userkey)
|
||||||
|
message = request.args.get('message')
|
||||||
print bookmark.url
|
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')
|
@app.route('/<userkey>/add')
|
||||||
@@ -249,10 +250,12 @@ def addingbookmark(userkey):
|
|||||||
if url:
|
if url:
|
||||||
#bookmark = Bookmark(url=url, title=title, starred=starred, userkey=userkey)
|
#bookmark = Bookmark(url=url, title=title, starred=starred, userkey=userkey)
|
||||||
bookmark, created = Bookmark.get_or_create(url=url, userkey=userkey)
|
bookmark, created = Bookmark.get_or_create(url=url, userkey=userkey)
|
||||||
print created
|
if not created:
|
||||||
if created:
|
return redirect(url_for('editbookmark', userkey=userkey, urlhash=bookmark.url_hash, message='Existing bookmark, did not overwrite with new values'))
|
||||||
bookmark.title = title
|
|
||||||
bookmark.starred = starred
|
# Newly created, set properties
|
||||||
|
bookmark.title = title
|
||||||
|
bookmark.starred = starred
|
||||||
bookmark.set_tags(tags)
|
bookmark.set_tags(tags)
|
||||||
bookmark.set_hash()
|
bookmark.set_hash()
|
||||||
#bookmark.fetch_image()
|
#bookmark.fetch_image()
|
||||||
|
|||||||
@@ -17,6 +17,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if message %}
|
||||||
|
<div class="col s12">
|
||||||
|
<div class="card-panel orange lighten-2">
|
||||||
|
<span class="white-text">
|
||||||
|
{{ message }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<form action="{{ url_for('addingbookmark', userkey=userkey) }}" method="POST">
|
<form action="{{ url_for('addingbookmark', userkey=userkey) }}" method="POST">
|
||||||
|
|
||||||
<div class="input-field col s12">
|
<div class="input-field col s12">
|
||||||
|
|||||||
Reference in New Issue
Block a user