API: refactor (rename mpwo_api to fittrackee_api)

This commit is contained in:
Sam 2018-06-07 14:15:27 +02:00
parent c314c79f86
commit 1f36de74ba
61 changed files with 52 additions and 52 deletions

View File

@ -1,4 +1,4 @@
[run] [run]
omit = omit =
mpwo_api/venv/* fittrackee_api/venv/*
mpwo_api/mpwo_api/tests/* fittrackee_api/fittrackee_api/tests/*

2
.gitignore vendored
View File

@ -6,7 +6,7 @@ Makefile.custom.config
# MPWO_API # MPWO_API
############### ###############
__pycache__ __pycache__
/mpwo_api/venv/ /fittrackee_api/venv/
uploads uploads
.cache .cache
.coverage .coverage

View File

@ -29,7 +29,7 @@ before_install:
before_script: before_script:
- export DATABASE_TEST_URL=postgres://postgres:@localhost:5432/mpwo_test - export DATABASE_TEST_URL=postgres://postgres:@localhost:5432/mpwo_test
- export APP_SETTINGS=mpwo_api.config.TestingConfig - export APP_SETTINGS=fittrackee_api.config.TestingConfig
- export REACT_APP_API_URL=http://127.0.0.1 - export REACT_APP_API_URL=http://127.0.0.1
- export NODE_ENV=development - export NODE_ENV=development
- export TEST_URL=http://127.0.0.1 - export TEST_URL=http://127.0.0.1

View File

@ -27,7 +27,7 @@ install-python:
lint-all: lint-python lint-react lint-all: lint-python lint-react
lint-python: lint-python:
$(PYTEST) --flake8 --isort -m "flake8 or isort" mpwo_api --ignore=mpwo_api/migrations $(PYTEST) --flake8 --isort -m "flake8 or isort" fittrackee_api --ignore=fittrackee_api/migrations
lint-react: lint-react:
$(NPM) lint $(NPM) lint
@ -48,10 +48,10 @@ test-e2e: init-db
$(NPM) test $(NPM) test
test-python: test-python:
$(PYTEST) mpwo_api --cov-config .coveragerc --cov=mpwo_api --cov-report term-missing $(PYTEST) fittrackee_api --cov-config .coveragerc --cov=fittrackee_api --cov-report term-missing
test-python-xml: test-python-xml:
$(PYTEST) mpwo_api --cov-config .coveragerc --cov=mpwo_api --cov-report xml $(PYTEST) fittrackee_api --cov-config .coveragerc --cov=fittrackee_api --cov-report xml
update-cov: test-python-xml update-cov: test-python-xml
$(COV) -r coverage.xml $(COV) -r coverage.xml

View File

@ -3,18 +3,18 @@ API_PORT = 5000
CLIENT_PORT = 3000 CLIENT_PORT = 3000
export REACT_APP_API_URL = http://$(HOST):$(API_PORT) export REACT_APP_API_URL = http://$(HOST):$(API_PORT)
export FLASK_APP = $(PWD)/mpwo_api/server.py export FLASK_APP = $(PWD)/fittrackee_api/server.py
export APP_SETTINGS=mpwo_api.config.DevelopmentConfig export APP_SETTINGS=fittrackee_api.config.DevelopmentConfig
export FLASK_ENV=development export FLASK_ENV=development
export TEST_URL = http://$(HOST):$(CLIENT_PORT) export TEST_URL = http://$(HOST):$(CLIENT_PORT)
export REQUIREMENTS = $(PWD)/mpwo_api/requirements.txt export REQUIREMENTS = $(PWD)/fittrackee_api/requirements.txt
export DATABASE_URL = postgres://mpwo:mpwo@$(HOST):5432/mpwo export DATABASE_URL = postgres://fittrackee:fittrackee@$(HOST):5432/fittrackee
export DATABASE_TEST_URL = postgres://mpwo:mpwo@$(HOST):5432/mpwo_test export DATABASE_TEST_URL = postgres://fittrackee:fittrackee@$(HOST):5432/fittrackee_test
export MIGRATIONS = $(PWD)/mpwo_api/migrations export MIGRATIONS = $(PWD)/fittrackee_api/migrations
# Python env # Python env
PYTHON_VERSION ?= python PYTHON_VERSION ?= python
VENV = $(PWD)/mpwo_api/venv VENV = $(PWD)/fittrackee_api/venv
PYTHON = $(VENV)/bin/python PYTHON = $(VENV)/bin/python
PIP = $(VENV)/bin/pip PIP = $(VENV)/bin/pip
FLASK = $(VENV)/bin/flask FLASK = $(VENV)/bin/flask

View File

@ -24,9 +24,9 @@ Maps are displayed using [Open Street Map](https://www.openstreetmap.org).
**Still under development (not ready for production).** **Still under development (not ready for production).**
(see [issues](https://github.com/SamR1/mpwo/issues) and [wiki](https://github.com/SamR1/mpwo/wiki) for more informations) (see [issues](https://github.com/SamR1/mpwo/issues) and [wiki](https://github.com/SamR1/mpwo/wiki) for more informations)
![mpwo screenshot](docs/images/mpwo_screenshot-01.png) ![FitTrackee screenshot](docs/images/fittrackee_screenshot-01.png)
![mpwo screenshot](docs/images/mpwo_screenshot-02.png) ![FitTrackee screenshot](docs/images/fittrackee_screenshot-02.png)
--- ---
Notes: Notes:

View File

@ -4,7 +4,7 @@ services:
mpwo-db: mpwo-db:
container_name: mpwo-db container_name: mpwo-db
build: https://github.com/SamR1/mpwo.git#master:mpwo_api/db build: https://github.com/SamR1/mpwo.git#master:fittrackee_api/db
ports: ports:
- 5435:5432 - 5435:5432
environment: environment:
@ -13,7 +13,7 @@ services:
mpwo-api: mpwo-api:
container_name: mpwo-api container_name: mpwo-api
build: https://github.com/SamR1/mpwo.git#master:mpwo_api build: https://github.com/SamR1/mpwo.git#master:fittrackee_api
ports: ports:
- 5001:5000 - 5001:5000
environment: environment:
@ -21,7 +21,7 @@ services:
- DATABASE_TEST_URL=postgres://postgres:postgres@mpwo-db:5432/mpwo_test - DATABASE_TEST_URL=postgres://postgres:postgres@mpwo-db:5432/mpwo_test
- FLASK_APP=server.py - FLASK_APP=server.py
- FLASK_DEBUG=1 - FLASK_DEBUG=1
- APP_SETTINGS=mpwo_api.config.TestingConfig - APP_SETTINGS=fittrackee_api.config.TestingConfig
depends_on: depends_on:
- mpwo-db - mpwo-db
links: links:

View File

@ -4,7 +4,7 @@ services:
mpwo-db: mpwo-db:
container_name: mpwo-db container_name: mpwo-db
build: ./mpwo_api/db build: ./fittrackee_api/db
ports: ports:
- 5435:5432 - 5435:5432
environment: environment:
@ -13,7 +13,7 @@ services:
mpwo-api: mpwo-api:
container_name: mpwo-api container_name: mpwo-api
build: ./mpwo_api build: ./fittrackee_api
ports: ports:
- 5001:5000 - 5001:5000
environment: environment:
@ -21,7 +21,7 @@ services:
- DATABASE_TEST_URL=postgres://postgres:postgres@mpwo-db:5432/mpwo_test - DATABASE_TEST_URL=postgres://postgres:postgres@mpwo-db:5432/mpwo_test
- FLASK_APP=server.py - FLASK_APP=server.py
- FLASK_DEBUG=1 - FLASK_DEBUG=1
- APP_SETTINGS=mpwo_api.config.DevelopmentConfig - APP_SETTINGS=fittrackee_api.config.DevelopmentConfig
depends_on: depends_on:
- mpwo-db - mpwo-db
links: links:

View File

Before

Width:  |  Height:  |  Size: 381 KiB

After

Width:  |  Height:  |  Size: 381 KiB

View File

Before

Width:  |  Height:  |  Size: 436 KiB

After

Width:  |  Height:  |  Size: 436 KiB

View File

@ -7,10 +7,10 @@ RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app WORKDIR /usr/src/app
# add requirements # add requirements
COPY ./requirements.txt /usr/src/app/mpwo_api/requirements.txt COPY ./requirements.txt /usr/src/app/fittrackee_api/requirements.txt
# install requirements # install requirements
RUN pip install -r mpwo_api/requirements.txt RUN pip install -r fittrackee_api/requirements.txt
# add app # add app
COPY . /usr/src/app COPY . /usr/src/app

View File

@ -0,0 +1,7 @@
DROP DATABASE IF EXISTS fittrackee;
DROP DATABASE IF EXISTS fittrackee_test;
CREATE DATABASE fittrackee;
CREATE DATABASE fittrackee_test;
CREATE USER fittrackee WITH PASSWORD 'fittrackee';
GRANT ALL PRIVILEGES ON DATABASE fittrackee TO fittrackee;
GRANT ALL PRIVILEGES ON DATABASE fittrackee_test TO fittrackee;

View File

@ -9,7 +9,7 @@ from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy() db = SQLAlchemy()
bcrypt = Bcrypt() bcrypt = Bcrypt()
migrate = Migrate() migrate = Migrate()
appLog = logging.getLogger('mpwo_api') appLog = logging.getLogger('fittrackee_api')
def create_app(): def create_app():

View File

@ -3,8 +3,8 @@ import os
import shutil import shutil
from datetime import datetime from datetime import datetime
from fittrackee_api import appLog, db
from flask import Blueprint, current_app, jsonify, request, send_file from flask import Blueprint, current_app, jsonify, request, send_file
from mpwo_api import appLog, db
from sqlalchemy import exc from sqlalchemy import exc
from ..users.utils import authenticate, verify_extension from ..users.utils import authenticate, verify_extension

View File

@ -1,7 +1,7 @@
import datetime import datetime
import os import os
from mpwo_api import db from fittrackee_api import db
from sqlalchemy.dialects import postgresql from sqlalchemy.dialects import postgresql
from sqlalchemy.event import listens_for from sqlalchemy.event import listens_for
from sqlalchemy.ext.hybrid import hybrid_property from sqlalchemy.ext.hybrid import hybrid_property

View File

@ -1,5 +1,5 @@
from fittrackee_api import appLog, db
from flask import Blueprint, jsonify, request from flask import Blueprint, jsonify, request
from mpwo_api import appLog, db
from sqlalchemy import exc from sqlalchemy import exc
from ..users.utils import authenticate, authenticate_as_admin from ..users.utils import authenticate, authenticate_as_admin

View File

@ -1,7 +1,7 @@
from datetime import datetime, timedelta from datetime import datetime, timedelta
from fittrackee_api import appLog
from flask import Blueprint, jsonify, request from flask import Blueprint, jsonify, request
from mpwo_api import appLog
from ..users.models import User from ..users.models import User
from ..users.utils import authenticate from ..users.utils import authenticate

View File

@ -5,8 +5,8 @@ import zipfile
from datetime import datetime, timedelta from datetime import datetime, timedelta
import gpxpy.gpx import gpxpy.gpx
from fittrackee_api import db
from flask import current_app from flask import current_app
from mpwo_api import db
from sqlalchemy import exc from sqlalchemy import exc
from staticmap import Line, StaticMap from staticmap import Line, StaticMap
from werkzeug.utils import secure_filename from werkzeug.utils import secure_filename

View File

@ -2,12 +2,12 @@ import datetime
import os import os
import pytest import pytest
from mpwo_api import create_app, db from fittrackee_api import create_app, db
from mpwo_api.activities.models import Activity, ActivitySegment, Sport from fittrackee_api.activities.models import Activity, ActivitySegment, Sport
from mpwo_api.users.models import User from fittrackee_api.users.models import User
os.environ["FLASK_ENV"] = 'testing' os.environ["FLASK_ENV"] = 'testing'
os.environ["APP_SETTINGS"] = 'mpwo_api.config.TestingConfig' os.environ["APP_SETTINGS"] = 'fittrackee_api.config.TestingConfig'
@pytest.fixture @pytest.fixture

View File

@ -2,7 +2,7 @@ import json
import os import os
from io import BytesIO from io import BytesIO
from mpwo_api.activities.models import Activity from fittrackee_api.activities.models import Activity
def assert_activity_data_with_gpx(data): def assert_activity_data_with_gpx(data):

View File

@ -2,7 +2,7 @@ import json
import os import os
from io import BytesIO from io import BytesIO
from mpwo_api.activities.models import Activity from fittrackee_api.activities.models import Activity
def get_gpx_filepath(activity_id): def get_gpx_filepath(activity_id):

View File

@ -2,7 +2,7 @@ import os
def test_development_config(app): def test_development_config(app):
app.config.from_object('mpwo_api.config.DevelopmentConfig') app.config.from_object('fittrackee_api.config.DevelopmentConfig')
assert app.config['DEBUG'] assert app.config['DEBUG']
assert not app.config['TESTING'] assert not app.config['TESTING']
assert app.config['SQLALCHEMY_DATABASE_URI'] == os.environ.get( assert app.config['SQLALCHEMY_DATABASE_URI'] == os.environ.get(
@ -10,7 +10,7 @@ def test_development_config(app):
def test_testing_config(app): def test_testing_config(app):
app.config.from_object('mpwo_api.config.TestingConfig') app.config.from_object('fittrackee_api.config.TestingConfig')
assert app.config['DEBUG'] assert app.config['DEBUG']
assert app.config['TESTING'] assert app.config['TESTING']
assert not app.config['PRESERVE_CONTEXT_ON_EXCEPTION'] assert not app.config['PRESERVE_CONTEXT_ON_EXCEPTION']

View File

@ -1,6 +1,6 @@
import datetime import datetime
from mpwo_api.activities.models import Record from fittrackee_api.activities.models import Record
def test_record_model( def test_record_model(

View File

@ -1,6 +1,6 @@
import json import json
from mpwo_api.users.models import User from fittrackee_api.users.models import User
def test_ping(app): def test_ping(app):

View File

@ -1,8 +1,8 @@
import datetime import datetime
import os import os
from fittrackee_api import appLog, bcrypt, db
from flask import Blueprint, current_app, jsonify, request from flask import Blueprint, current_app, jsonify, request
from mpwo_api import appLog, bcrypt, db
from sqlalchemy import exc, or_ from sqlalchemy import exc, or_
from werkzeug.utils import secure_filename from werkzeug.utils import secure_filename

View File

@ -1,8 +1,8 @@
import datetime import datetime
import jwt import jwt
from fittrackee_api import bcrypt, db
from flask import current_app from flask import current_app
from mpwo_api import bcrypt, db
from sqlalchemy import func from sqlalchemy import func
from ..activities.models import Activity from ..activities.models import Activity

View File

@ -1,8 +1,8 @@
import shutil import shutil
from mpwo_api import create_app, db from fittrackee_api import create_app, db
from mpwo_api.activities.models import Sport from fittrackee_api.activities.models import Sport
from mpwo_api.users.models import User from fittrackee_api.users.models import User
app = create_app() app = create_app()

View File

@ -1,7 +0,0 @@
DROP DATABASE IF EXISTS mpwo;
DROP DATABASE IF EXISTS mpwo_test;
CREATE DATABASE mpwo;
CREATE DATABASE mpwo_test;
CREATE USER mpwo WITH PASSWORD 'mpwo';
GRANT ALL PRIVILEGES ON DATABASE mpwo TO mpwo;
GRANT ALL PRIVILEGES ON DATABASE mpwo_test TO mpwo;