Web client interface for Open Concept Lab terminology services API.
Docker
Before starting the web project, you need to start the API as described in https://github.com/OpenConceptLab/oclapi
To run the server in a development mode use: docker-compose up
To take down the server use: docker-compose down
To take down the server and drop all data: docker-compose down -v
Using PyCharm 2017.2
- Start the server in development mode.
- Import the project into PyCharm by pointing to ocl_web as root directory
- Go to Settings -> Project: ocl_web -> Project Interpreter
- Click the cog icon and Add Remote
- Choose SSH Credentials and fill in the form as follows:
Host: localhost
Port: 2001
User name: root
Password: Root123
Python interpreter path: /usr/local/bin/python
- Accept all warnings regarding certificates.
- Close settings with OK
- Go to Run -> Edit Configurations...
- Click the plus icon and choose Django server
- Fill in the form as follows (adjust working directory and path mappings accordingly):
Name: oclweb
Host: 0.0.0.0
Port: 7001
Working directory: C:\Users\Rafal\Workspace\ocl_web\
Path mappings: C:/Users/Rafal/Workspace/ocl_web/=/code
- Confirm with OK and debug with the newly created configuration.
- Go to https://localhost:7001 to verify it works.
By default the OCL WEB server runs against OCL API at 8000. If you want to run it against an OCL API debug server, open the debug configuration and add the following environment variable:
OCL_API_HOST=https://172.17.0.1:8001'
docker-compose run web bash run_unit_tests.sh
docker build -t openconceptlab/oclweb:dev .
docker run --rm openconceptlab/oclweb:dev bash run_ui_tests.sh
Please see https://github.com/OpenConceptLab/oclapi/blob/jetstream/README.md#continuous-integration
-
ocl_web
- Fork the repo on Github
- Clone your fork locally
git clone https://github.com/{youruser}/ocl_web.git
- Add a remote repo to upstream in order to be able to fetch updates:
cd ocl_web git remote add upstream https://github.com/OpenConceptLab/ocl_web
-
python
-
npm
-
pip
-
python virtualenv
pip install virtualenv
- OCL API must be setup, up and running.
-
Change working directory to repository root
cd ocl_web
-
Create a virtualenv for the project (NOTE: "env" is the name of virtualenv by convention, but you can give it any name, just be sure to add it to the ignores list in git)
virtualenv env #Creates a virtual environment
-
Create the file that will be used as the DB for ocl_web
touch ocl.db
-
Activate the virtual environment created in step 2 . For deactivation of virtual env just write 'deactivate'. (NOTE: Replace "env" with the directory name you used to create your virtual environment)
source ./env/bin/activate
-
Set the environment variables below to let OCL Web connect to API and set the DB location. Note that OclAPI must be already setup for this, you can see the token at https://0.0.0.0:8000/admin/authtoken/token/ (8000 is the port where oclapi server is running). Note that for a local development environment, OCL_API_HOST will typically be set to
https://localhost:8000
.export OCL_API_HOST='<your_api_server_ip>' export OCL_API_TOKEN='<root_token_from_api>' export OCL_ANON_API_TOKEN='<root_token_from_api>' export DATABASE_URL=sqlite:https:////<OCL_WEB_ROOT>/ocl.db
-
Install python and node.js dependencies -- NOTE: Make sure your version of pip in your virtualenv is up-to-date (e.g. pip install --upgrade pip)
pip install -r requirements/local.txt npm install
-
Install grunt cli
npm install -g grunt-cli
-
Prepare database (create tables for models and apply migrations)
python ocl_web/manage.py syncdb #You will be prompted to create an ocl_web superuser python ocl_web/manage.py migrate
-
Create a user. Make sure to get status=201 on the output. Otherwise the user is not created.
python ocl_web/manage.py create_test_user --username <username> --password <password>
-
Serve the application
grunt serve
- Application should be up at https://localhost:7000 and you should be able to login with the user created in step 9
OCL_WEB has a suite of unit tests written in python (django test) and end-to-end tests written in protractor running either headless (PhantomJS) or Chrome.
- Unit Tets
python ocl_web/manage.py test
- Running E2E tests
- Headless on showcase server:
./run_ui_tests.sh
- Locally on Chrome:
OCL_WEB=. browser=phantomjs env=local username=<username> password=<pwd> ./run_ui_tests.sh
cookiecutter-django relies extensively on environment settings which will not work with Apache/mod_wsgi setups. It has been deployed successfully with both Gunicorn/Nginx and even uWSGI/Nginx.
For configuration purposes, the following table maps the cookiecutter-django environment variables to their Django setting:
Environment Variable | Django Setting | Development Default | Production Default |
---|---|---|---|
DJANGO_AWS_ACCESS_KEY_ID | AWS_ACCESS_KEY_ID | n/a | raises error |
DJANGO_AWS_SECRET_ACCESS_KEY | AWS_SECRET_ACCESS_KEY | n/a | raises error |
DJANGO_AWS_STORAGE_BUCKET_NAME | AWS_STORAGE_BUCKET_NAME | n/a | raises error |
DJANGO_CACHES | CACHES | locmem | memcached |
DJANGO_DEBUG | DEBUG | True | False |
DJANGO_EMAIL_BACKEND | EMAIL_BACKEND | django.core.mail.backends.console.EmailBackend | django.core.mail.backends.smtp.EmailBackend |
DJANGO_SECRET_KEY | SECRET_KEY | CHANGEME!!! | raises error |
DJANGO_SECURE_BROWSER_XSS_FILTER | SECURE_BROWSER_XSS_FILTER | n/a | True |
DJANGO_SECURE_SSL_REDIRECT | SECURE_SSL_REDIRECT | n/a | True |
DJANGO_SECURE_CONTENT_TYPE_NOSNIFF | SECURE_CONTENT_TYPE_NOSNIFF | n/a | True |
DJANGO_SECURE_FRAME_DENY | SECURE_FRAME_DENY | n/a | True |
DJANGO_SECURE_HSTS_INCLUDE_SUBDOMAINS | SECURE_HSTS_INCLUDE_SUBDOMAINS | n/a | True |
DJANGO_SESSION_COOKIE_HTTPONLY | SESSION_COOKIE_HTTPONLY | n/a | True |
DJANGO_SESSION_COOKIE_SECURE | SESSION_COOKIE_SECURE | n/a | False |
- TODO: Add vendor-added settings in another table
Copyright (C) 2016 Open Concept Lab. Use of this software is subject to the terms of the Mozille Public License v2.0. Open Concept Lab is also distributed under the terms the Healthcare Disclaimer described at https://www.openconceptlab.org/license/.