Skip to content

FlaskCon/traveller

Repository files navigation

Traveller

Setup

Create venv named venv inside root folder

Activate it

Install requirements.txt

$ python -m pip install -r requirements/reqs.txt
Debug install (Linux only):

Run if install issues:
(cat requirements/reqs.txt; echo "") | grep "^[^#]" | xargs -L 1 pip install

May need to manually install an older version of Flask:
pip install Flask==2.2.2

We are using MySQL but you can have a stab at a different db.

Create a db named traveller or whatever you want in your MySQL db.

Setting up the database with docker-compose

Note: You may need to change the docker-compose.yml file is you have changed the username or password of instance/config.py

Install docker and docker-compose

```bash
sudo apt install docker.io
sudo apt install docker-compose

Adjust permissions for docker

sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker

Start docker service

sudo systemctl start docker

Ensure you are in the root directory of the project:

traveller/ <- You are here
├── traveller/
│   requirements/
│   etc...
├── docker-compose.yml

Run docker-compose

docker-compose up -d

You can navigate to http://localhost:8080 to access phpmyadmin.

The default username and password are both root

The database can be accessed at localhost:3306 providing you have not changed any defaults.

Setting up MySQL Database on Linux (if this is your first time with using MySQL database )

  • Start MySQL database

    $ systemctl start mysql

(or)

$ service mysql start
  • After starting MySQL database, login into the shell

    $ mysql
  • Create a database

  mysql >

CREATE DATABASE traveller;
  • This will create the database in your local MySQL server, you can exit the Mysql shell and complete the remaining steps

Continuing the installation

Change directory to the traveller folder

$ cd traveller

Create folder called instance and a file called config.py in it

$ mkdir instance #auto ignored by git
$ touch instance/config.py

In instance/config.py set the SQLALCHEMY_URI. For MySQL it will be like this (the file should contain only that):

SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://root:root@localhost/traveller'

'mysql+pymysql://username:password@localhost/dbname'.

Create or edit traveller/config.json with the information needed for each environment.

for development:

{
"environment": "development",
"admin_user": {
"email": "admin@domain.com",
"password": "pass"
},
"settings": {
"APP_NAME": "Demo",
"ACTIVE_FRONT_THEME": "blogus",
"ACTIVE_BACK_THEME": "boogle",
"CURRENCY": "MUR"
}
}

and for production:

{
"environment": "production",
"admin_user": {
"email": "admin@domain.com",
"password": "pass"
},
"settings": {
"APP_NAME": "Demo",
"ACTIVE_FRONT_THEME": "blogus",
"ACTIVE_BACK_THEME": "boogle",
"CURRENCY": "MUR"
}
}

Now in traveller/traveller run:

$ python manage.py initialise

Then, to get development example data (make sure requirements in requirements/dev.txt are installed)

$ flask seed dev

Then

$ python manage.py rundebug

Migrations:

$ python manage.py db migrate
$ python manage.py db upgrade

More info can be found in the shopyo docs: shopyo.readthedocs.io

Setup Mail Dev Environment

We are using flask-mailman.

If you have Node.js, use the maildev package. Install it using

$ npm install -g maildev

Then serve it using

$ maildev

Dev configs for this setup are (already in config.py):

class DevelopmentConfig(Config):
    """Configurations for development"""

    ENV = "development"
    DEBUG = True
    LOGIN_DISABLED = False
    # control email confirmation for user registration
    EMAIL_CONFIRMATION_DISABLED = False
    # flask-mailman configs
    MAIL_SERVER = 'localhost'
    MAIL_PORT = 1025
    MAIL_USE_TLS = False
    MAIL_USE_SSL = False
    MAIL_USERNAME = ''  # os.environ.get("MAIL_USERNAME")
    MAIL_PASSWORD = ''  # os.environ.get("MAIL_PASSWORD")
    MAIL_DEFAULT_SENDER = 'ma@mail.com'  # os.environ.get("MAIL_DEFAULT_SENDER")

Go to http://127.0.0.1:1080 where it serves it’s web interface by default. See mails arrive in your inbox! Particularly useful when registering!

Running tests

Go to traveller/traveller

$ python -m pytest .

Some functionalities of app

Go to: http://127.0.0.1:5000/dashboard

Login with username: admin@domain.com and password: pass

Click on admin and create a new role called reviewer

Add new people and assign them the roles

Go to dashboard and click on conf

Create a new conf

Add reviewers to conf

Go to: http://127.0.0.1:5000/y/2021/

We'll db seed some folks soon