Skip to content

Commit

Permalink
Merge branch 'demo'
Browse files Browse the repository at this point in the history
  • Loading branch information
jefmoura committed Feb 15, 2018
2 parents 2ee2063 + 102a210 commit 3969864
Show file tree
Hide file tree
Showing 99 changed files with 2,305 additions and 3,530 deletions.
14 changes: 8 additions & 6 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
pipeline:
build:
test:
image: python:${PYTHON_VERSION}
commands:
- pip install -r requirements-ci.txt
- pip install -r requirements/ci.txt
- python manage.py test
when:
event: [push, tag]
Expand All @@ -13,7 +13,9 @@ pipeline:
- TOLA_DB_USER=root
- TOLA_DB_PASS=root
- TOLA_DB_HOST=postgres
- TOLA_TRACK_SYNC_ENABLED=False
- DEFAULT_ORG=TolaData

build-docker-image:
image: plugins/docker
insecure: true
Expand All @@ -26,7 +28,7 @@ pipeline:
secrets: [DOCKER_USERNAME, DOCKER_PASSWORD]
when:
event: [push, tag]
branches: [master, dev-v2]
branch: [master, demo, staging]
status: [success]

trigger-deployment:
Expand All @@ -41,7 +43,7 @@ pipeline:
params: "APP_ID=/tolaactivity,APP_GROUP=toladata,APP_NAME=TolaActivity,APP_BRANCH=${DRONE_COMMIT_BRANCH},APP_COMMIT=${DRONE_COMMIT_SHA},APP_TAG=${DRONE_TAG},APP_IMAGE=registry.tola.io/toladata/tolaactivity:${DRONE_COMMIT_SHA}"
when:
event: [push, tag]
branches: [master, dev-v2]
branch: [master, demo, staging]
status: [success]

notify:
Expand All @@ -50,9 +52,9 @@ pipeline:
username: Drone-CI
secrets: [SLACK_WEBHOOK]
when:
status: [failure]
event: [push, tag]
branches: [master, dev-v2]
branch: [master, demo, staging]
status: [failure]

services:
postgres:
Expand Down
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ addons:
before_script:
- sleep 10
install:
- cat requirements.txt | grep "^Django==\|^psycopg2" | xargs pip install
- pip install -r requirements-pkg.txt
- cat requirements/base.txt | grep "^Django==\|^psycopg2" | xargs pip install
- pip install -r requirements/pkg.txt
script:
- python manage.py test --tag=pkg
- pip install -r requirements-ci.txt
- pip install -r requirements/ci.txt
- coverage run --source='.' manage.py test -v 2
- coverage report
after_success:
Expand All @@ -26,6 +26,7 @@ env:
- TOLA_DB_USER=postgres
- TOLA_DB_PASS=
- TOLA_DB_PORT=5432
- TOLA_TRACK_SYNC_ENABLED=False
- ELASTICSEARCH_URL=http://127.0.0.1:9200/
- COVERALLS_REPO_TOKEN=e4x1YSoHzZd9c7lmIu880ghTMniH24YLq
- DEFAULT_ORG=TolaData
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ WORKDIR /code
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install nginx -y

ADD docker/etc/nginx/nginx.conf /etc/nginx/nginx.conf
ADD docker/etc/nginx/tola.conf /etc/nginx/conf.d/tola.conf

RUN pip install -r requirements.txt
RUN pip install -r requirements/production.txt

EXPOSE 8000
EXPOSE 8080

CMD ["sh", "-c", "/code/docker-entrypoint.sh"]
ENTRYPOINT ["/code/docker-entrypoint.sh"]
8 changes: 4 additions & 4 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ FROM python:2.7

WORKDIR /code

COPY ./requirements-pkg.txt requirements-pkg.txt
COPY ./requirements.txt requirements.txt
COPY ./requirements-dev.txt requirements-dev.txt
COPY ./requirements/pkg.txt requirements/pkg.txt
COPY ./requirements/base.txt requirements/base.txt
COPY ./requirements/dev.txt requirements/dev.txt

RUN pip install -r requirements-dev.txt
RUN pip install -r requirements/dev.txt

ADD . /code

Expand Down
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ To run the package building tests, follow these steps:
```bash
docker-compose -f docker-compose-dev.yml run --entrypoint '/usr/bin/env' --rm web bash
# Now inside the container
pip freeze | grep -v "^-e" | xargs pip uninstall -y; pip uninstall -y social_auth_core; cat requirements.txt | grep "^Django==\|^psycopg2" | xargs pip install; pip install -r requirements-pkg.txt
pip freeze | grep -v "^-e" | xargs pip uninstall -y; pip uninstall -y social_auth_core; cat requirements/base.txt | grep "^Django==\|^psycopg2" | xargs pip install; pip install -r requirements/pkg.txt
python manage.py test --tag=pkg --keepdb
```

Expand Down Expand Up @@ -89,6 +89,13 @@ around with Activity:
docker-compose -f docker-compose-dev.yml run --entrypoint '/usr/bin/env' --rm web python manage.py loadinitialdata --demo
```

(Be careful using this, only on demo!) If the database is already populated and
you want to restore the default data:

```bash
docker-compose -f docker-compose-dev.yml run --entrypoint '/usr/bin/env' --rm web python manage.py loadinitialdata --restore
```

#### Issue with the local environment

If you're getting an error in your local environment, it can be related to
Expand Down Expand Up @@ -139,7 +146,7 @@ source venv/bin/activate
Install requirements:

```bash
pip install -r requirements-dev.txt
pip install -r requirements/dev.txt
```

Set up database:
Expand Down Expand Up @@ -175,6 +182,13 @@ Then set up the following environment variables in docker-compose-dev.yml:
* `SOCIAL_AUTH_MICROSOFT_GRAPH_REDIRECT_URL=https://<ID>.ngrok.io/complete/microsoft-graph`
* `TOLA_HOSTNAME=127.0.0.1,localhost,<ID>.ngrok.io`

To perform the Microsoft login you have to access the TolaActivity through the ngrok given URL, e.g., `https://<ID>.ngrok.io` otherwise you'll get an error related to the state (session).
### Setup Gunicorn and NGINX reverse proxy and static file server
In order to have this stack in development, follow the instructions detailed
in commit [730f79eb57e24f36691f63994e9ed01d0ae2ac08](https://github.com/toladata/TolaActivity/commit/730f79eb57e24f36691f63994e9ed01d0ae2ac08)
## Creating PRs and Issues
The following templates were created to easy the way to create tickets and help the developer.
Expand Down
9 changes: 0 additions & 9 deletions customdashboard/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from django.db import models
from django.contrib import admin

from workflow.models import WorkflowLevel1


Expand All @@ -17,11 +15,4 @@ class Meta:
verbose_name_plural = "Jupyter Notebooks"

def __unicode__(self):

return self.name


class JupyterNotebooksAdmin(admin.ModelAdmin):
list_display = ('name','workflowlevel1','very_custom_dashboard','create_date','edit_date')
display = 'Jupyter Notebooks'

18 changes: 0 additions & 18 deletions customdashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,21 +475,3 @@ def Notebook(request,id=0):
"""
getNotebook = JupyterNotebooks.objects.get(id=id)
return render(request, "customdashboard/notebook.html", {'getNotebook':getNotebook})

#RRIMA JupyterView (in use 12/16)
def RRIMAJupyterView1(request,id=0):
"""
RRIMA custom dashboard TODO: Migrate this to the existing configurable dashboard
:param request:
:param id:
:return:
"""
model = WorkflowLevel1
workflowlevel1_id = 1#id ##USE TURKEY workflowlevel1 ID HERE
# getworkflowlevel1 = workflowlevel1.objects.all().filter(id=workflowlevel1_id)

## retrieve the coutries the user has data access for
countries = getCountry(request.user)
with open('static/rrima.html') as myfile: data = "\n".join(line for line in myfile)

return HttpResponse(data)
10 changes: 7 additions & 3 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ services:
- elasticsearch
environment:
- DJANGO_SETTINGS_MODULE=tola.settings.dev
- TOLA_DEBUG=True
- TOLA_ERROR_LOG=error.log
- TOLA_HOSTNAME=127.0.0.1,localhost
- TOLA_DB_ENGINE=django.db.backends.postgresql_psycopg2
Expand All @@ -55,12 +54,17 @@ services:
- TOLA_DB_HOST=postgres
- TOLA_DB_PORT=5432
- ELASTICSEARCH_URL=http://elasticsearch:9200/
- SOCIAL_AUTH_GOOGLE_OAUTH2_KEY=445847194486-gl2v6ud6ll65vf06vbjaslqqgejad61k.apps.googleusercontent.com
- SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET=qAAdNMQy77Vwqgj4YgOu20f7
- SOCIAL_AUTH_GOOGLE_OAUTH2_KEY=1090285679254-ep8e9kh2p2juqq8u169fqr5ijfnuaihm.apps.googleusercontent.com
- SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET=kfy1DGJ3POZYtWMGX0l1yoMi
- SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS=toladata.com,humanitec.com,treeaid.org,gmail.com
- SOCIAL_AUTH_LOGIN_REDIRECT_URL=http://dev-v2.tolaactivity.app.tola.io/
- SOCIAL_AUTH_MICROSOFT_GRAPH_KEY=63783b55-0c15-4e94-8ceb-4de040fea71d
- SOCIAL_AUTH_MICROSOFT_GRAPH_SECRET=w8zgk5dz5JVErCNzc8Jz7EM
- SOCIAL_AUTH_MICROSOFT_GRAPH_REDIRECT_URL=https://localhost:8000/complete/microsoft-graph
- TOLA_ACTIVITY_URL=http://tolaactivity.dev.com
- TOLA_TRACK_URL=http://tolatrack.dev.com
- DEFAULT_ORG=TolaData
- CHARGEBEE_SIGNUP_ORG_URL=https://toladata-test.chargebee.com/hosted_pages/plans/monthly?addons[id][0]=user&addons[quantity][0]=1
- CHARGEBEE_SITE_API_KEY=test_31lcdE7L3grqdkGcvy24ik3lmlJrnA0Ez
- CHARGEBEE_SITE=toladata-test
- TOLA_TRACK_SYNC_ENABLED=False
10 changes: 0 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,6 @@ web:
- "8000"
links:
- postgres:postgres
volumes:
- /Users/glind/Projects/toladata/tolaactivity
- /Users/glind/Projects/toladata/tolaactivity/static
environment:
- DEBUG=1
- TOLA_HOSTNAME=dev-v2.tolaactivity.app.tola.io
- SOCIAL_AUTH_GOOGLE_OAUTH2_KEY=445847194486-gl2v6ud6ll65vf06vbjaslqqgejad61k.apps.googleusercontent.com
- SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET=qAAdNMQy77Vwqgj4YgOu20f7
- SOCIAL_AUTH_LOGIN_REDIRECT_URL=http://dev-v2.tolaactivity.app.tola.io/

command: /usr/local/bin/gunicorn docker_django.wsgi:application -w 2 -b :8000

nginx:
Expand Down
3 changes: 0 additions & 3 deletions docker-entrypoint-dev.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/bin/bash

echo "Collect static files"
python manage.py collectstatic -v 0 --noinput

echo "Migrate"
python manage.py migrate

Expand Down
6 changes: 5 additions & 1 deletion docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ set -o xtrace
echo "Migrate"
python manage.py migrate

echo "Collect static files"
python manage.py collectstatic

RESULT=$?

nginx;

if [ $RESULT -eq 0 ]; then
echo "Running the server"
gunicorn -b 127.0.0.1:8888 tola.wsgi
service nginx restart
gunicorn -b 0.0.0.0:8080 tola.wsgi
else
pushd templates2/maintenance/; python -m SimpleHTTPServer 8888; popd
fi
20 changes: 20 additions & 0 deletions docker/etc/nginx/tola.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
server {
listen 8000;
server_name localhost;

location /static/ {
autoindex off;
alias /static/;
}

location = /favicon.ico {
root /static/img;
}

location / {
proxy_redirect off;
proxy_pass_request_headers on;
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
}
}
20 changes: 0 additions & 20 deletions docs/Makefile

This file was deleted.

21 changes: 0 additions & 21 deletions docs/source/AuthenticationStatusCode.rst

This file was deleted.

Loading

0 comments on commit 3969864

Please sign in to comment.