def show_user_tag(name): links = Link.get_by_tag(name, current_user.userid) title = 'My Tagged Links - "%s"' % name return render_template('link_index.html', pageoptions=get_default_data(), user=current_user, links=links, section_title=title, page_title=title)
def do_bulk_edit(tags): # Redirect filters immediately if request.args.get('tag_select'): return redirect( url_for('do_bulk_edit', tags=request.args.get('tag_select'))) available_tags = Tag.get_by_user(current_user.userid) if request.method == 'POST': linkids = request.form.getlist('linkids') edit_links = Link.get_by_id(linkids) valid = _links_are_valid(edit_links) tag_text = request.form.get('tag_text') if valid and tag_text and request.form.get('tag_submit'): for link in edit_links: link.add_tag(tag_text) link.save() flash('Tagged %d links as "%s"' % (len(edit_links), tag_text), 'success') elif valid and tag_text and request.form.get('tag_remove'): for link in edit_links: link.remove_tag(tag_text) link.save() flash( 'Removed tag "%s" from %d links' % (tag_text, len(edit_links)), 'success') if valid and request.form.get('set_privacy') and request.form.get( 'privacy_submit'): _set_link_privacy(edit_links, request.form.get('set_privacy')) if valid and request.form.get('delete_selected_submit'): for link in edit_links: link.delete() flash('Deleted %s links' % len(edit_links), 'success') if tags == 'untagged': title = 'Manage Untagged Links' links = Link.get_untagged(current_user.userid) elif tags: taglist = tags.split(',') title = 'Manage Links in ' + tags links = Link.get_by_tag(taglist[0], current_user.userid) else: title = "Manage Links" links = Link.get_by_user(current_user.userid) return render_template("link_edit_bulk.html", pageoptions=get_default_data(), url_tags=tags, links=links, section_title=title, tags=available_tags)
def test_get_by_tag_nonexistent_hasuser(self): result = Link.get_by_tag('this does not exist', 1) self.assertEqual(len(result), 0)
def test_get_by_tag_exists_hasuser(self): result = Link.get_by_tag('test1', 1) self.assertEqual(len(result), 3)
def test_get_by_tag_exists_nouser(self): result = Link.get_by_tag('test1') self.assertEqual(len(result), 4)
def get_module_data(self): return Link.get_by_tag(self.configuration.tag_name, self.userid)