def userbookmarks(username): if not username: return redirect('/recent', 302) user = User.User(username=username) if user.ID: amount, start = amountstart() b = Bookmark.Bookmark() bookmarks = b.get_bookmarks(userID=user.ID, amount=amount, start=start) f = Feed.Feed() feedentries = f.get_by_bookmarks(bookmarks) if f.get_by_bookmarks( bookmarks) else [] feeds = {} for feedid, entryid, d in feedentries: if not feeds.get('feed%s' % feedid, None): feeds['feed%s' % feedid] = Feed.Feed(feedid) feeds['feed%s' % feedid].entries.append(Entry.Entry(entryid)) return render_template("recent.html", feeds=feeds.values(), amount=amount, menu=usermenu(), title='Bookmarks by: %s' % username, path="/%s/bookmarks" % username, nextstart=int(start) + int(amount), prevstart=max(int(start) - int(amount), -1)), 200, { 'Cache-Control': 's-maxage=1' }
def remove_bookmark(bookmarkID): user = User.User() if user.verify(session.get('das_hash', None)): Bookmark.Bookmark(ID=int(bookmarkID)).delete() return ('', 204)
def bookmark(entryID): result = {'error': 'Log in to use bookmark'} user = User.User() if user.verify(session.get('das_hash', None)): result = Bookmark.Bookmark().add(userID=user.ID, entryID=entryID) return jsonify(result)
def test_bookmarked(self): b = bookmark.Bookmark() self.assertIsNone(b.bookmarked(userID=1, entryID=1)) self.assertFalse(b.bookmarked(userID=None, entryID=1)) self.assertFalse(b.bookmarked(userID=1, entryID=None)) self.assertTrue(b.bookmarked(userID=1, entryID=20383))
def test_gat_bookamrks(self): b = bookmark.Bookmark() self.assertGreater(len(b.get_bookmarks(1)), 2)
def test_init(self): b = bookmark.Bookmark() self.assertEqual(b.ID, None)