def show_user_tag_list(username): if username is None: username = current_user.username user = current_user elif current_user and username == current_user.username: user = current_user else: user = User.get_by_username(username) user_owned = current_user and current_user.username == username if user_owned: tags = Tag.get_cloud_by_user(user.userid) title = "My Tags" else: tags = Tag.get_public_by_user(user.userid) title = 'Tags for %s' % username return render_template('tag_index.html', pageoptions=get_default_data(), tags=tags, curr_user=current_user, page_title=title, section_title=title, user_owned=user_owned, user=user)
def show_user(username): usr = User.get_by_username(username) links = Link.get_public_by_most_recent(usr.userid, 30) tags = Tag.get_public_by_user(usr.userid) return render_template('public_dashboard.html', pageoptions=get_default_data(), tags=tags, links=links, user=usr, curr_user=current_user)
def show_all_user_tagged(name, username): user = User.get_by_username(username) links = Link.get_public_by_tag(name, user.userid) title = 'Links for tag "%s" by %s' % (name, user.username) return render_template('link_index.html', pageoptions=get_default_data(), user=user, curr_user=current_user, links=links, section_title=title, page_title=title)
def do_login(): #if current_user: #return redirect(url_for('show_index')) if request.method == 'POST': valid = False curr_user = User.get_by_username(request.form.get('username')) if curr_user: valid = curr_user.check_password(request.form.get('password')) if valid: login_user(curr_user) return make_response( redirect(request.form.get('referer') or url_for('show_index'))) error = 'Either your username or password is wrong' return render_template('login.html', pageoptions=get_default_data(), error=error) return render_template('login.html', pageoptions=get_default_data())
def show_user_index(username): if username is None: usr = current_user else: usr = User.get_by_username(username) if not usr: abort(404) if usr is current_user: links = Link.get_by_user(current_user.userid) else: links = Link.get_public_by_user(usr.userid) return render_template('link_index.html', pageoptions=get_default_data(), links=links, user=current_user)
def test_get_by_username_nonexistent(self): usr = User.get_by_username('thisuserdoesnotexist') self.assertEqual(usr, None)
def test_get_by_username_exists(self): usr = User.get_by_username('testuser') self.assertEqual(usr.username, 'testuser')