API - remove intermediate directory and rename api directory
@ -1,4 +1,4 @@
|
||||
[run]
|
||||
omit =
|
||||
fittrackee_api/.venv/*
|
||||
fittrackee_api/fittrackee_api/tests/*
|
||||
fittrackee/.venv/*
|
||||
fittrackee/tests/*
|
||||
|
6
.flake8
@ -1,5 +1,5 @@
|
||||
[flake8]
|
||||
per-file-ignores =
|
||||
fittrackee_api/fittrackee_api/activities/stats.py:E501
|
||||
fittrackee_api/fittrackee_api/tests/test_email.py:E501
|
||||
fittrackee_api/fittrackee_api/tests/test_email_template_password_request.py:E501
|
||||
fittrackee/activities/stats.py:E501
|
||||
fittrackee/tests/test_email.py:E501
|
||||
fittrackee/tests/test_email_template_password_request.py:E501
|
||||
|
2
.gitignore
vendored
@ -12,7 +12,7 @@ uploads
|
||||
coverage.xml
|
||||
.pytest_cache
|
||||
.venv
|
||||
/fittrackee_api.egg-info/
|
||||
/fittrackee.egg-info/
|
||||
|
||||
# MPWO_CLIENT
|
||||
###############
|
||||
|
@ -5,10 +5,10 @@ variables:
|
||||
POSTGRES_USER: fittrackee
|
||||
POSTGRES_PASSWORD: fittrackee
|
||||
POSTGRES_HOST: postgres
|
||||
APP_SETTINGS: fittrackee_api.config.TestingConfig
|
||||
APP_SETTINGS: fittrackee.config.TestingConfig
|
||||
DATABASE_TEST_URL: postgres://fittrackee:fittrackee@postgres:5432/fittrackee_test
|
||||
EMAIL_URL: smtp://none:none@0.0.0.0:1025
|
||||
FLASK_APP: fittrackee_api/server.py
|
||||
FLASK_APP: fittrackee/server.py
|
||||
SENDER_EMAIL: fittrackee@example.com
|
||||
|
||||
services:
|
||||
@ -26,12 +26,12 @@ stages:
|
||||
- poetry config virtualenvs.create false
|
||||
- poetry install --no-interaction --quiet
|
||||
script:
|
||||
- pytest fittrackee_api -p no:warnings --cov fittrackee_api --cov-report term-missing
|
||||
- pytest fittrackee -p no:warnings --cov fittrackee --cov-report term-missing
|
||||
|
||||
lint:
|
||||
extends: .python
|
||||
script:
|
||||
- pytest --flake8 --isort --black -m "flake8 or isort or black" fittrackee_api e2e --ignore=fittrackee_api/migrations
|
||||
- pytest --flake8 --isort --black -m "flake8 or isort or black" fittrackee e2e --ignore=fittrackee/migrations
|
||||
|
||||
python-3.7:
|
||||
extends: .python
|
||||
@ -51,7 +51,7 @@ firefox:
|
||||
- pip install --quiet poetry
|
||||
- poetry config virtualenvs.create false
|
||||
- poetry install --no-interaction --quiet
|
||||
- flask db upgrade --directory fittrackee_api/migrations
|
||||
- flask db upgrade --directory fittrackee/migrations
|
||||
- flask initdata
|
||||
- setsid nohup flask run --with-threads -h 0.0.0.0 -p 5000 >> nohup.out 2>&1 &
|
||||
- export TEST_APP_URL=http://$(hostname --ip-address):5000
|
||||
|
18
Makefile
@ -25,7 +25,7 @@ html:
|
||||
cp -a docsrc/build/html/. docs
|
||||
|
||||
install-db:
|
||||
psql -U postgres -f fittrackee_api/db/create.sql
|
||||
psql -U postgres -f db/create.sql
|
||||
$(FLASK) db upgrade --directory $(MIGRATIONS)
|
||||
$(FLASK) initdata
|
||||
|
||||
@ -58,10 +58,10 @@ lint-all: lint-python lint-react
|
||||
lint-all-fix: lint-python-fix lint-react-fix
|
||||
|
||||
lint-python:
|
||||
$(PYTEST) --flake8 --isort --black -m "flake8 or isort or black" fittrackee_api e2e --ignore=fittrackee_api/migrations
|
||||
$(PYTEST) --flake8 --isort --black -m "flake8 or isort or black" fittrackee e2e --ignore=fittrackee/migrations
|
||||
|
||||
lint-python-fix:
|
||||
$(BLACK) fittrackee_api e2e
|
||||
$(BLACK) fittrackee e2e
|
||||
|
||||
lint-react:
|
||||
$(NPM) lint
|
||||
@ -82,7 +82,7 @@ run:
|
||||
$(MAKE) P="run-server run-workers" make-p
|
||||
|
||||
run-server:
|
||||
cd fittrackee_api && $(GUNICORN) -b 127.0.0.1:5000 "fittrackee_api:create_app()" --error-logfile ../gunicorn.log
|
||||
cd fittrackee && $(GUNICORN) -b 127.0.0.1:5000 "fittrackee:create_app()" --error-logfile ../gunicorn.log
|
||||
|
||||
run-workers:
|
||||
$(FLASK) worker --processes=$(WORKERS_PROCESSES) >> dramatiq.log 2>&1
|
||||
@ -103,19 +103,13 @@ serve-dev:
|
||||
$(MAKE) P="serve-react serve-python-dev" make-p
|
||||
|
||||
test-e2e: init-db
|
||||
$(PYTEST) e2e --driver firefox $(PYTEST_ARGS) $(E2E_ARGS)
|
||||
$(PYTEST) e2e --driver firefox $(PYTEST_ARGS)
|
||||
|
||||
test-e2e-client: init-db
|
||||
E2E_ARGS=client $(PYTEST) e2e --driver firefox $(PYTEST_ARGS)
|
||||
|
||||
test-python:
|
||||
$(PYTEST) fittrackee_api --cov-config .coveragerc --cov=fittrackee_api --cov-report term-missing $(PYTEST_ARGS)
|
||||
|
||||
test-python-xml:
|
||||
$(PYTEST) fittrackee_api --cov-config .coveragerc --cov=fittrackee_api --cov-report xml
|
||||
|
||||
update-cov: test-python-xml
|
||||
$(COV) -r coverage.xml
|
||||
$(PYTEST) fittrackee --cov-config .coveragerc --cov=fittrackee --cov-report term-missing $(PYTEST_ARGS)
|
||||
|
||||
upgrade-db:
|
||||
$(FLASK) db upgrade --directory $(MIGRATIONS)
|
||||
|
@ -2,14 +2,14 @@ HOST = 0.0.0.0
|
||||
API_PORT = 5000
|
||||
CLIENT_PORT = 3000
|
||||
|
||||
export FLASK_APP = $(PWD)/fittrackee_api/server.py
|
||||
export APP_SETTINGS=fittrackee_api.config.DevelopmentConfig
|
||||
export FLASK_APP = $(PWD)/fittrackee/server.py
|
||||
export APP_SETTINGS=fittrackee.config.DevelopmentConfig
|
||||
export FLASK_ENV=development
|
||||
export TEST_APP_URL = http://$(HOST):$(API_PORT)
|
||||
export TEST_CLIENT_URL = http://$(HOST):$(CLIENT_PORT)
|
||||
export DATABASE_URL = postgres://fittrackee:fittrackee@$(HOST):5432/fittrackee
|
||||
export DATABASE_TEST_URL = postgres://fittrackee:fittrackee@$(HOST):5432/fittrackee_test
|
||||
export MIGRATIONS = $(PWD)/fittrackee_api/migrations
|
||||
export MIGRATIONS = $(PWD)/fittrackee/migrations
|
||||
|
||||
# Python env
|
||||
PYTHON_VERSION ?= python
|
||||
@ -19,7 +19,6 @@ POETRY = poetry
|
||||
FLASK = $(VENV)/bin/flask
|
||||
PYTEST = $(VENV)/bin/py.test -c pyproject.toml -W ignore::DeprecationWarning
|
||||
GUNICORN = $(VENV)/bin/gunicorn
|
||||
COV = $(VENV)/bin/python-codacy-coverage
|
||||
BLACK = $(VENV)/bin/black
|
||||
|
||||
# Node env
|
||||
|
@ -1,7 +1,7 @@
|
||||
Activities
|
||||
##########
|
||||
|
||||
.. autoflask:: fittrackee_api:create_app()
|
||||
.. autoflask:: fittrackee:create_app()
|
||||
:endpoints:
|
||||
activities.get_activities,
|
||||
activities.get_activity,
|
||||
|
@ -1,7 +1,7 @@
|
||||
Authentication
|
||||
##############
|
||||
|
||||
.. autoflask:: fittrackee_api:create_app()
|
||||
.. autoflask:: fittrackee:create_app()
|
||||
:endpoints:
|
||||
auth.register_user,
|
||||
auth.login_user,
|
||||
|
@ -1,7 +1,7 @@
|
||||
Configuration
|
||||
#############
|
||||
|
||||
.. autoflask:: fittrackee_api:create_app()
|
||||
.. autoflask:: fittrackee:create_app()
|
||||
:endpoints:
|
||||
config.get_application_config,
|
||||
config.update_application_config,
|
||||
|
@ -1,6 +1,6 @@
|
||||
Records
|
||||
#######
|
||||
|
||||
.. autoflask:: fittrackee_api:create_app()
|
||||
.. autoflask:: fittrackee:create_app()
|
||||
:endpoints:
|
||||
records.get_records
|
||||
|
@ -1,7 +1,7 @@
|
||||
Sports
|
||||
######
|
||||
|
||||
.. autoflask:: fittrackee_api:create_app()
|
||||
.. autoflask:: fittrackee:create_app()
|
||||
:endpoints:
|
||||
sports.get_sports,
|
||||
sports.get_sport,
|
||||
|
@ -1,7 +1,7 @@
|
||||
Statistics
|
||||
##########
|
||||
|
||||
.. autoflask:: fittrackee_api:create_app()
|
||||
.. autoflask:: fittrackee:create_app()
|
||||
:endpoints:
|
||||
stats.get_activities_by_time,
|
||||
stats.get_activities_by_sport,
|
||||
|
@ -1,7 +1,7 @@
|
||||
Users
|
||||
#####
|
||||
|
||||
.. autoflask:: fittrackee_api:create_app()
|
||||
.. autoflask:: fittrackee:create_app()
|
||||
:endpoints:
|
||||
users.get_users,
|
||||
users.get_single_user,
|
||||
|
@ -144,7 +144,7 @@ Upgrade
|
||||
.. warning::
|
||||
| Before upgrading, make a backup of all data:
|
||||
| - database (with `pg_dump <https://www.postgresql.org/docs/11/app-pgdump.html>`__ for instance)
|
||||
| - upload directory: **FitTrackee/fittrackee_api/fittrackee_api/uploads/**
|
||||
| - upload directory: **FitTrackee/fittrackee/fittrackee_api/uploads/**
|
||||
|
||||
|
||||
Dev environment
|
||||
|
@ -293,7 +293,7 @@ password</p>
|
||||
<div class="line-block">
|
||||
<div class="line">Before upgrading, make a backup of all data:</div>
|
||||
<div class="line">- database (with <a class="reference external" href="https://www.postgresql.org/docs/11/app-pgdump.html">pg_dump</a> for instance)</div>
|
||||
<div class="line">- upload directory: <strong>FitTrackee/fittrackee_api/fittrackee_api/uploads/</strong></div>
|
||||
<div class="line">- upload directory: <strong>FitTrackee/fittrackee/fittrackee_api/uploads/</strong></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="id2">
|
||||
|
@ -1,7 +1,7 @@
|
||||
Activities
|
||||
##########
|
||||
|
||||
.. autoflask:: fittrackee_api:create_app()
|
||||
.. autoflask:: fittrackee:create_app()
|
||||
:endpoints:
|
||||
activities.get_activities,
|
||||
activities.get_activity,
|
||||
|
@ -1,7 +1,7 @@
|
||||
Authentication
|
||||
##############
|
||||
|
||||
.. autoflask:: fittrackee_api:create_app()
|
||||
.. autoflask:: fittrackee:create_app()
|
||||
:endpoints:
|
||||
auth.register_user,
|
||||
auth.login_user,
|
||||
|
@ -1,7 +1,7 @@
|
||||
Configuration
|
||||
#############
|
||||
|
||||
.. autoflask:: fittrackee_api:create_app()
|
||||
.. autoflask:: fittrackee:create_app()
|
||||
:endpoints:
|
||||
config.get_application_config,
|
||||
config.update_application_config,
|
||||
|
@ -1,6 +1,6 @@
|
||||
Records
|
||||
#######
|
||||
|
||||
.. autoflask:: fittrackee_api:create_app()
|
||||
.. autoflask:: fittrackee:create_app()
|
||||
:endpoints:
|
||||
records.get_records
|
||||
|
@ -1,7 +1,7 @@
|
||||
Sports
|
||||
######
|
||||
|
||||
.. autoflask:: fittrackee_api:create_app()
|
||||
.. autoflask:: fittrackee:create_app()
|
||||
:endpoints:
|
||||
sports.get_sports,
|
||||
sports.get_sport,
|
||||
|
@ -1,7 +1,7 @@
|
||||
Statistics
|
||||
##########
|
||||
|
||||
.. autoflask:: fittrackee_api:create_app()
|
||||
.. autoflask:: fittrackee:create_app()
|
||||
:endpoints:
|
||||
stats.get_activities_by_time,
|
||||
stats.get_activities_by_sport,
|
||||
|
@ -1,7 +1,7 @@
|
||||
Users
|
||||
#####
|
||||
|
||||
.. autoflask:: fittrackee_api:create_app()
|
||||
.. autoflask:: fittrackee:create_app()
|
||||
:endpoints:
|
||||
users.get_users,
|
||||
users.get_single_user,
|
||||
|
@ -16,7 +16,7 @@ from pathlib import Path
|
||||
|
||||
import sphinx_bootstrap_theme
|
||||
|
||||
sys.path.insert(0, os.path.abspath('../../fittrackee_api'))
|
||||
sys.path.insert(0, os.path.abspath('../../fittrackee'))
|
||||
|
||||
|
||||
def setup(app):
|
||||
|
@ -144,7 +144,7 @@ Upgrade
|
||||
.. warning::
|
||||
| Before upgrading, make a backup of all data:
|
||||
| - database (with `pg_dump <https://www.postgresql.org/docs/11/app-pgdump.html>`__ for instance)
|
||||
| - upload directory: **FitTrackee/fittrackee_api/fittrackee_api/uploads/**
|
||||
| - upload directory: **FitTrackee/fittrackee/fittrackee_api/uploads/**
|
||||
|
||||
|
||||
Dev environment
|
||||
|
@ -15,21 +15,19 @@ bcrypt = Bcrypt()
|
||||
migrate = Migrate()
|
||||
email_service = Email()
|
||||
dramatiq = Dramatiq()
|
||||
appLog = logging.getLogger('fittrackee_api')
|
||||
appLog = logging.getLogger('fittrackee')
|
||||
|
||||
|
||||
def create_app():
|
||||
# instantiate the app
|
||||
app = Flask(
|
||||
__name__, static_folder='../dist/static', template_folder='../dist'
|
||||
)
|
||||
app = Flask(__name__, static_folder='dist/static', template_folder='dist')
|
||||
|
||||
# set config
|
||||
with app.app_context():
|
||||
app_settings = os.getenv('APP_SETTINGS')
|
||||
if app_settings == 'fittrackee_api.config.TestingConfig':
|
||||
if app_settings == 'fittrackee.config.TestingConfig':
|
||||
# reload config on tests
|
||||
config = import_module('fittrackee_api.config')
|
||||
config = import_module('fittrackee.config')
|
||||
reload(config)
|
||||
app.config.from_object(app_settings)
|
||||
|
@ -4,7 +4,7 @@ import shutil
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import requests
|
||||
from fittrackee_api import appLog, db
|
||||
from fittrackee import appLog, db
|
||||
from flask import Blueprint, Response, current_app, jsonify, request, send_file
|
||||
from sqlalchemy import exc
|
||||
|
@ -1,7 +1,7 @@
|
||||
import datetime
|
||||
import os
|
||||
|
||||
from fittrackee_api import db
|
||||
from fittrackee import db
|
||||
from sqlalchemy.dialects import postgresql
|
||||
from sqlalchemy.event import listens_for
|
||||
from sqlalchemy.ext.hybrid import hybrid_property
|
@ -1,4 +1,4 @@
|
||||
from fittrackee_api import appLog, db
|
||||
from fittrackee import appLog, db
|
||||
from flask import Blueprint, jsonify, request
|
||||
from sqlalchemy import exc
|
||||
|
@ -1,6 +1,6 @@
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from fittrackee_api import appLog, db
|
||||
from fittrackee import appLog, db
|
||||
from flask import Blueprint, jsonify, request
|
||||
from sqlalchemy import func
|
||||
|
@ -6,7 +6,7 @@ from datetime import datetime, timedelta
|
||||
|
||||
import gpxpy.gpx
|
||||
import pytz
|
||||
from fittrackee_api import appLog, db
|
||||
from fittrackee import appLog, db
|
||||
from flask import current_app
|
||||
from sqlalchemy import exc
|
||||
from staticmap import Line, StaticMap
|
@ -2,7 +2,7 @@ import os
|
||||
|
||||
import forecastio
|
||||
import pytz
|
||||
from fittrackee_api import appLog
|
||||
from fittrackee import appLog
|
||||
|
||||
API_KEY = os.getenv('WEATHER_API')
|
||||
|
@ -1,4 +1,4 @@
|
||||
from fittrackee_api import appLog, db
|
||||
from fittrackee import appLog, db
|
||||
from flask import Blueprint, current_app, jsonify, request
|
||||
from sqlalchemy.orm.exc import MultipleResultsFound, NoResultFound
|
||||
|
@ -1,4 +1,4 @@
|
||||
from fittrackee_api import db
|
||||
from fittrackee import db
|
||||
from flask import current_app
|
||||
from sqlalchemy.event import listens_for
|
||||
|
@ -1,7 +1,7 @@
|
||||
import os
|
||||
|
||||
from fittrackee_api import db
|
||||
from fittrackee_api.users.models import User
|
||||
from fittrackee import db
|
||||
from fittrackee.users.models import User
|
||||
|
||||
from .models import AppConfig
|
||||
|
@ -4,7 +4,7 @@ from dramatiq.brokers.redis import RedisBroker
|
||||
from dramatiq.brokers.stub import StubBroker
|
||||
from flask import current_app
|
||||
|
||||
if os.getenv('APP_SETTINGS') == 'fittrackee_api.config.TestingConfig':
|
||||
if os.getenv('APP_SETTINGS') == 'fittrackee.config.TestingConfig':
|
||||
broker = StubBroker
|
||||
else:
|
||||
broker = RedisBroker
|
Before Width: | Height: | Size: 318 B After Width: | Height: | Size: 318 B |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 1012 B After Width: | Height: | Size: 1012 B |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 637 B After Width: | Height: | Size: 637 B |
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |