System Overview
Initial Prototype (COMP204P)
Our prototype for COMP204p is an Flask application, INcDb User. The application is based on the Flask-User-starter-app as we will be using the Flask extension, Flask-User, to implement our user management functionality. The source code of the INcDb User is on https://github.com/UCL-CS35/incdb-user.
Add Relevant Fields
Beside the basic user management functionality from the starter app, we added 2 new fields, title and affiliation to reflect our project requirements.
Support latest version Flask-User
As the starter-app is dependent on an older version of Flask-User, we updated the code to support the latest version of Flask-User.
Unit Testing
We also introduce test cases to experiment with pytest, our selected testing tool. See Testing Strategy for more information about testing.
Screenshots
Setup
Install Virtual Environment using pip:
pip install virtualenv
Cloning the app
mkdir INcDb
cd INcDb
git clone https://github.com/UCL-CS35/incdb-user.git incdb-user
Create the ‘incdb-user’ virtual environment
mkvirtualenv incdb_user_env
Install required Python packages
cd /path/to/incdb-user
workon incdb_user_env
pip install -r requirements.txt
Configuring the app Copy the app/env_settings_example.py to an env_settings.py that resides outside the code directory and point the OS environment variable ENV_SETTINGS_FILE to this file.
# Copy env_settings.py and place it outside of the code directory
cd /path/to/project
cp app/env_settings_example.py ../env_settings.py
# Point the OS environment variable `ENV_SETTINGS_FILE` to this file
export ENV_SETTINGS_FILE=/path/to/env_settings.py
Before deploying this application, we will have to configure the database URL and SMTP account that will be used to access the database and to send emails.
Initializing the Database
# Create DB tables and populate the roles and users tables
python manage.py init_db
Running the app
# Start the Flask development web server
./runserver.sh # will run "python manage.py runserver"
Point your web browser to http://localhost:5000/
You can make use of the following users:
- email user@example.com with password Password1.
- email admin@example.com with password Password1.
Data Model for INcDb User
Users Table
id | confirmed_at | password | reset_password_token | active | first_name | last_name | title | affiliation | |
---|---|---|---|---|---|---|---|---|---|
Roles Table
id | name | label |
---|---|---|
User Roles Table
id | user_id | role_id |
---|---|---|
Dependency for INcDb User
Flask Framework | Flask Extensions | Development Tools |
---|---|---|
Flask |
Flask-Migrate Flask-SQLAlchemy Flask-User Flask-WTF |
pytest pytest-flask pytest-cov selenium |