This repository contains final project for Full Stack Web Development with Flask
course from pirple.com website.
Link to the working site is here.
-
Setup and activate your local python environment. Here are few guides on how to do it.
-
Install requirements:
pip install requirements.txt
-
Create
.env
file:cp app/.env.template app/.env
-
Setup PostgreSQL. You have few options:
4.1. you can use any already existing PostgreSQL (in docker, in any cloud provider, etc):
- create new database;
- update
DATABASE_URL
in.env
file;
4.2. you can setup PostgreSQL locally:
- for example, you can use this guide or any other guide;
- after setting up PostgreSQL locally create new database:
psql postgres -c 'create database save_favourite_color;'
-
Apply migrations to your database:
flask db upgrade
-
Run application:
flask run
-
Go to 127.0.0.1:5000 in your web browser.
To run tests use following command:
python -m pytest
Note: tests will be run using DATABASE_URL
, so if you don't want to lose your data, you may create new database and update DATABASE_URL
.
If you want to check code coverage use following command:
python -m pytest --cov=app
Right now the site offers following features:
- Register new users.
- Login into user's account.
- Logout from user's account.
- For unknown urls show 404 page.
- Admin accounts:
- Admins can add new colors to database from appropriate separate page.
- Admins can see a list of all users with their info on appropriate separate page.
- Admins can deactivate users from appropriate separate page.
- Share link to user's favourite color.
Below is a list of what needs to be done:
- Migrate from SQLite to PostgreSQL
- Let users edit their favourite color.
- Cover project with tests.
- Run tests on github.
- Use
werkzeug.security
for passwords instead of plain text. - Add admin accounts:
- Add
is_admin
field tousers
tableor create completely different table for admins. - Admin homepage should look like the one for regular user.
- Allow admin to add colors to
colors
table (add link to appropriate page to the upper right corner). - Allow admin to see a list of all users with their info (add link to appropriate page to the upper right corner).
- Allow admin to deactivate users (add link to appropriate page to the upper right corner).
- Add
- Let users share link to their favourite color. The page should include content from the one for logged-in user, but:
- text should be the following - "{color} is the favourite color of {username}.";
- block with color filling should remain;
- header should look like the one for not logged-in user.