Skip to content

Zirochkaa/save-favourite-color

Repository files navigation

pytest

Save favourite color

This repository contains final project for Full Stack Web Development with Flask course from pirple.com website.

Link to the working site is here.

Run project locally

  1. Setup and activate your local python environment. Here are few guides on how to do it.

  2. Install requirements:

    pip install requirements.txt
  3. Create .env file:

    cp app/.env.template app/.env
  4. Setup PostgreSQL. You have few options:

    4.1. you can use any already existing PostgreSQL (in docker, in any cloud provider, etc):

    1. create new database;
    2. update DATABASE_URL in .env file;

    4.2. you can setup PostgreSQL locally:

    1. for example, you can use this guide or any other guide;
    2. after setting up PostgreSQL locally create new database:
      psql postgres -c 'create database save_favourite_color;'
  5. Apply migrations to your database:

    flask db upgrade
  6. Run application:

    flask run
  7. Go to 127.0.0.1:5000 in your web browser.

Tests

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

Features

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.

TODOs

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 to users table or 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).
  • 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.

About

Fastapi application designed for saving person's favourite color.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published