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

Delete button through its own form

This commit is contained in:
2016-07-20 15:31:58 +02:00
parent ce9915fbf9
commit 81e3b93cb5
2 changed files with 14 additions and 3 deletions

View File

@@ -87,7 +87,7 @@ class Bookmark(db.Model):
# if exitcode == 0: # if exitcode == 0:
# self.image = os.path.join(MEDIA_URL, filename) # self.image = os.path.join(MEDIA_URL, filename)
def sethash(self): def set_hash(self):
""" Generate hash """ """ Generate hash """
self.url_hash = hashlib.md5(self.url).hexdigest() self.url_hash = hashlib.md5(self.url).hexdigest()
@@ -136,7 +136,7 @@ class Bookmark(db.Model):
def get_tags_for_user(userkey): def get_tags_for_user(userkey):
""" Extract all tags from the bookmarks """ """ Extract all tags from the bookmarks """
bookmarks = Bookmark.select(Bookmark.userkey==userkey) bookmarks = Bookmark.select(Bookmark.userkey == userkey)
tags = [] tags = []
for bookmark in bookmarks: for bookmark in bookmarks:
these_tags = bookmark.tags.split(',') these_tags = bookmark.tags.split(',')
@@ -208,7 +208,7 @@ def addingbookmark(userkey):
tags = request.form['tags'] tags = request.form['tags']
if url: if url:
bookmark = Bookmark(url=url, title=title, tags=tags, userkey=userkey) bookmark = Bookmark(url=url, title=title, tags=tags, userkey=userkey)
bookmark.sethash() bookmark.set_hash()
#bookmark.fetch_image() #bookmark.fetch_image()
if not title: if not title:
# Title was empty, automatically fetch it from the url, will also update the status code # Title was empty, automatically fetch it from the url, will also update the status code
@@ -226,6 +226,13 @@ def addingbookmark(userkey):
return redirect(url_for('add')) return redirect(url_for('add'))
@app.route('/<userkey>/<urlhash>/delete', methods=['GET', 'POST'])
def deletingbookmark(userkey, urlhash):
""" Delete the bookmark from form submit by <urlhash>/delete """
# TODO implement
return redirect(url_for('bookmarks', userkey=userkey))
@app.route('/<userkey>/tags') @app.route('/<userkey>/tags')
def tags(userkey): def tags(userkey):
""" Overview of all tags used by user """ """ Overview of all tags used by user """

View File

@@ -46,9 +46,13 @@
<div class="input-field col l2 m3 s4"> <div class="input-field col l2 m3 s4">
<p class="left-align"><button class="btn btn-large waves-effect waves-light" type="submit" name="submit">Save</button></p> <p class="left-align"><button class="btn btn-large waves-effect waves-light" type="submit" name="submit">Save</button></p>
</div> </div>
</form>
{% if bookmark.url_hash %}
<form class="col s12" action="{{ url_for('deletingbookmark', userkey=userkey, urlhash=bookmark.url_hash) }}" method="POST">
<div class="input-field col l2 m3 s4"> <div class="input-field col l2 m3 s4">
<p class="left-align"><button class="btn btn-large waves-effect waves-light" type="button" name="delete">Delete</button></p> <p class="left-align"><button class="btn btn-large waves-effect waves-light" type="button" name="delete">Delete</button></p>
</div> </div>
</form> </form>
{% endif %}
</div> </div>
{% endblock %} {% endblock %}