Skip to content

Zirochkaa/save-favourite-color

Repository files navigation

pytest Coverage Status

Save favourite color

This repository contains pet project - fastapi application designed for saving person's favourite color :)

Link to the working site here - color.zirochka.me (currently turned off).

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 -r requirements-ci.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:

    gunicorn -c gunicorn_config.py "app:create_app()"
  7. Go to 127.0.0.1:8080 in your web browser.

Tests

To run tests use following command:

python -m pytest

Note: tests will be run using DATABASE_URL_TEST, so you need to create new database and update DATABASE_URL_TEST.

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 see a list of all colors with their info on appropriate separate page.
    • 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.
  • Use flask-debugtoolbar.
  • Migrate from PostgreSQL to MongoDB.
  • Add admin accounts:
    • Add is_admin field to users table or create completely different table for admins.
    • All pages for admin user should look the same as the ones for regular user.
    • Allow admin to see a list of all colors with their info (link to appropriate page should be in admin panel).
    • Allow admin to add colors to colors table (link to appropriate page should be in admin panel).
    • Allow admin to see a list of all users with their info (link to appropriate page should be in admin panel).
    • Allow admin to deactivate users (link to appropriate page should be in admin panel).
  • Let users share link to their favourite color. This page should:
    • have the following text at the center oh the screen - "{color} is the favourite color of {username}.";
    • have a block with color filling;
    • show headers like 404 page meaning that some headers should be shown for logged-in user (like Setting, Log out, etc.) and some other headers should be shown for not logged-in user (like Log in, Sign up, etc.).

About

Fastapi application designed for saving person's favourite color.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published