implement bookmark deletion

This commit is contained in:
Jakob Ketterl
2021-02-14 16:51:16 +01:00
parent 29a161b7b7
commit 48c594fdae
4 changed files with 36 additions and 3 deletions

View File

@ -60,7 +60,7 @@ class BookmarksController(AuthorizationMixin, WebpageController):
<td class="frequency">{frequency}</td>
<td data-value="{modulation}">{modulation_name}</td>
<td>
<div class="btn btn-sm btn-danger bookmark-delete">delete</div>
<button class="btn btn-sm btn-danger bookmark-delete">delete</button>
</td>
</tr>
""".format(
@ -111,5 +111,16 @@ class BookmarksController(AuthorizationMixin, WebpageController):
except json.JSONDecodeError:
self.send_response("{}", content_type="application/json", code=400)
def delete(self):
bookmark_id = int(self.request.matches.group(1))
bookmark = self._findBookmark(bookmark_id)
if bookmark is None:
self.send_response("{}", content_type="application/json", code=404)
return
bookmarks = Bookmarks.getSharedInstance()
bookmarks.removeBookmark(bookmark)
bookmarks.store()
self.send_response("{}", content_type="application/json", code=200)
def indexAction(self):
self.serve_template("settings/bookmarks.html", **self.template_variables())