def searchSavedOthers(handler): handler.title('Saved Searches') requirePriv(handler, 'User') print tabs.where('others') undelay(handler) print "<style type=\"text/css\">" print ".other-search {padding-bottom: 4px; border-bottom: 1px dashed #000;}" print ".other-search h2 {margin-bottom: 4px;}" print ".other-search small {float: right; font-weight: normal; font-size: 12pt;}" print ".other-search code {font-size: 14pt;}" print "</style>" searches = filter(lambda search: search.user != handler.session['user'] and search.public, SavedSearch.loadAll(orderby = 'name')) if searches == []: print "No shared searches available" else: for search in searches: print "<div class=\"other-search\">" print "<h2>%s<small><img class=\"bumpdown\" src=\"%s\"> %s</small></h2>" % (search.safe.name, search.user.getAvatar(16), search.user.username) print "<code>%s</code><br><br>" % search.safe.query following = handler.session['user'] in search.followers print "<form method=\"post\" action=\"/search/saved/%d/%s\">" % (search.id, 'unfollow' if following else 'follow') print Button('Run', url = "/search/saved/%d/run" % search.id) btn = Button('Unfollow' if following else 'Follow', type = 'submit') if following: btn.negative() else: btn.positive() print btn print "</form>" print "</div>"