This app uses PostgreSQL and connects to a database named 'warbler'. Be sure to create the database in psql:
CREATE DATABASE warblerRun the following commands in the terminal:
python3 -m venv venvto create a virtual environmentpip3 install -r requirements.txtto install the current dependencies in the necessary versionssource venv/bin/activateto activate the virtual environmentflask runto start the flask server and run the program
If you would like to start the program with prepopulated data to play around with, please run the following command in ipython:
%run seed.pyrun the seed file to prepopulate the database with users, posts, and profile info
In a nutshell, the schema is many-to-many. One User may create many Messages, may follow many Users, may like many Messages by many Users.
An unlogged-in user is always redirected to the login/register page. A logged-in user is directed to their own homepage, where their stats (messages/follows/followers) are displayed, as well as the most recent messages posted by users they have followed.
A logged-in user may:
- Follow another user
- Like another user's message
- View their followers
- View who they are following
- Create a new message
- View the messages they have created
- View the messages they have liked
- Unlike a message
- Unfollow a user
- View another user's profile
- View their own profile
- Edit their own profile
- Delete their account
A logged-in user may not:
- Alter or delete messages, likes, follows, followers, or profiles of another user
- Like their own messages
- Follow themselves
To run the tests, make sure you create the 'warbler-test' PostgreSQL database with psql.
CREATE DATABASE warbler-test- test_message_model.py
This file contains tests for the Message model in models.py, inlcuding 'like' functionality.
- test_message_views.py
This file contains tests for all the view funcs in app.py related to Messages, including authentication.
- test_user_model.py
This file contains tests for the User model in models.py, including user registration, login, the relationship between User and Message, the functionality of Follows, and the functionality of Likes.
- test_user_views.py
This file contains tests for all the view funcs in app.py related to Users, including login verification and authentication, redirection, searching and displaying Users, and likes and follows functionality.