Welcome to Warbler’s documentation!

App

app.add_csrf_form_to_g()

add a wtform to g to protect csrf attack

app.add_follow(follow_id)

Add a follow for the currently-logged-in user.

app.add_header(response)

Add non-caching headers on every request.

app.add_user_to_g()

If we’re logged in, add curr user to Flask global.

app.delete_user(user_id)

Delete user.

app.do_login(user)

Log in user.

app.do_logout()

Logout user.

app.homepage()

Show homepage:

  • anon users: no messages

  • logged in: 100 most recent messages of followed_users

app.liked_messages(user_id)

Display all messages that are liked by current user

app.list_users()

Page with listing of users.

Can take a ‘q’ param in querystring to search by that username.

app.login()

Handle user login.

app.logout()

Handle logout of user.

app.message_like_or_unlike(message_id)

Like/Unlike a message

app.messages_add()

Add a message:

Show form if GET. If valid, update message and redirect to user page.

app.messages_destroy(message_id)

Delete a message.

app.messages_show(message_id)

Show a message.

app.profile()

Update profile for current user.

app.show_following(user_id)

Show list of people this user is following.

app.signup()

Handle user signup.

Create new user and add to DB. Redirect to home page.

If form not valid, present form.

If the there already is a user with that username: flash message and re-present form.

app.stop_following(follow_id)

Have currently-logged-in-user stop following this user.

app.users_followers(user_id)

Show list of followers of this user.

app.users_show(user_id)

Show user profile.

Model

SQLAlchemy models for Warbler.

class models.Follows(**kwargs)

Bases: sqlalchemy.orm.decl_api.Model

Connection of a follower <-> followed_user.

class models.Like(**kwargs)

Bases: sqlalchemy.orm.decl_api.Model

Like association between users and messages.

class models.Message(**kwargs)

Bases: sqlalchemy.orm.decl_api.Model

An individual message (“warble”).

is_liked_by(user)

check whether the message is liked by a user. Return a boolean value…

serialize()

returns the instance as a python dictionary

class models.User(**kwargs)

Bases: sqlalchemy.orm.decl_api.Model

User in the system.

classmethod authenticate(username, password)

Find user with username and password.

This is a class method (call it on the class, not an individual user.) It searches for a user whose password hash matches this password and, if it finds such a user, returns that user object.

If can’t find matching user (or if password is wrong), returns False.

is_followed_by(other_user)

Is this user followed by other_user?

is_following(other_user)

Is this user following other_user?

classmethod signup(username, email, password, image_url)

Sign up user.

Hashes password and adds user to system.

models.connect_db(app)

Connect this database to provided Flask app.

You should call this in your Flask app.

Form

class forms.CSRFForm(*args, **kwargs)

Bases: flask_wtf.form.FlaskForm

Form for deleting posts

class forms.LoginForm(*args, **kwargs)

Bases: flask_wtf.form.FlaskForm

Login form.

class forms.MessageForm(*args, **kwargs)

Bases: flask_wtf.form.FlaskForm

Form for adding/editing messages.

class forms.UserAddForm(*args, **kwargs)

Bases: flask_wtf.form.FlaskForm

Form for adding users.

class forms.UserEditForm(*args, **kwargs)

Bases: flask_wtf.form.FlaskForm

Form for editing users.

Indices and tables