mirror of
https://github.com/aquatix/digimarks.git
synced 2025-12-06 22:05:09 +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 = 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()
|
||||
|
||||
@@ -17,6 +17,17 @@
|
||||
</div>
|
||||
</div>
|
||||
{% 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">
|
||||
|
||||
<div class="input-field col s12">
|
||||
|
||||
Reference in New Issue
Block a user