API - remove intermediate directory and rename api directory

This commit is contained in:
Sam 2020-09-16 15:41:02 +02:00
parent 640385cdb7
commit af301b437e
148 changed files with 1953 additions and 1967 deletions

View File

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

View File

@ -1,5 +1,5 @@
[flake8] [flake8]
per-file-ignores = per-file-ignores =
fittrackee_api/fittrackee_api/activities/stats.py:E501 fittrackee/activities/stats.py:E501
fittrackee_api/fittrackee_api/tests/test_email.py:E501 fittrackee/tests/test_email.py:E501
fittrackee_api/fittrackee_api/tests/test_email_template_password_request.py:E501 fittrackee/tests/test_email_template_password_request.py:E501

2
.gitignore vendored
View File

@ -12,7 +12,7 @@ uploads
coverage.xml coverage.xml
.pytest_cache .pytest_cache
.venv .venv
/fittrackee_api.egg-info/ /fittrackee.egg-info/
# MPWO_CLIENT # MPWO_CLIENT
############### ###############

View File

@ -5,10 +5,10 @@ variables:
POSTGRES_USER: fittrackee POSTGRES_USER: fittrackee
POSTGRES_PASSWORD: fittrackee POSTGRES_PASSWORD: fittrackee
POSTGRES_HOST: postgres POSTGRES_HOST: postgres
APP_SETTINGS: fittrackee_api.config.TestingConfig APP_SETTINGS: fittrackee.config.TestingConfig
DATABASE_TEST_URL: postgres://fittrackee:fittrackee@postgres:5432/fittrackee_test DATABASE_TEST_URL: postgres://fittrackee:fittrackee@postgres:5432/fittrackee_test
EMAIL_URL: smtp://none:none@0.0.0.0:1025 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 SENDER_EMAIL: fittrackee@example.com
services: services:
@ -26,12 +26,12 @@ stages:
- poetry config virtualenvs.create false - poetry config virtualenvs.create false
- poetry install --no-interaction --quiet - poetry install --no-interaction --quiet
script: 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: lint:
extends: .python extends: .python
script: 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: python-3.7:
extends: .python extends: .python
@ -51,7 +51,7 @@ firefox:
- pip install --quiet poetry - pip install --quiet poetry
- poetry config virtualenvs.create false - poetry config virtualenvs.create false
- poetry install --no-interaction --quiet - poetry install --no-interaction --quiet
- flask db upgrade --directory fittrackee_api/migrations - flask db upgrade --directory fittrackee/migrations
- flask initdata - flask initdata
- setsid nohup flask run --with-threads -h 0.0.0.0 -p 5000 >> nohup.out 2>&1 & - 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 - export TEST_APP_URL=http://$(hostname --ip-address):5000

View File

@ -25,7 +25,7 @@ html:
cp -a docsrc/build/html/. docs cp -a docsrc/build/html/. docs
install-db: install-db:
psql -U postgres -f fittrackee_api/db/create.sql psql -U postgres -f db/create.sql
$(FLASK) db upgrade --directory $(MIGRATIONS) $(FLASK) db upgrade --directory $(MIGRATIONS)
$(FLASK) initdata $(FLASK) initdata
@ -58,10 +58,10 @@ lint-all: lint-python lint-react
lint-all-fix: lint-python-fix lint-react-fix lint-all-fix: lint-python-fix lint-react-fix
lint-python: 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: lint-python-fix:
$(BLACK) fittrackee_api e2e $(BLACK) fittrackee e2e
lint-react: lint-react:
$(NPM) lint $(NPM) lint
@ -82,7 +82,7 @@ run:
$(MAKE) P="run-server run-workers" make-p $(MAKE) P="run-server run-workers" make-p
run-server: 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: run-workers:
$(FLASK) worker --processes=$(WORKERS_PROCESSES) >> dramatiq.log 2>&1 $(FLASK) worker --processes=$(WORKERS_PROCESSES) >> dramatiq.log 2>&1
@ -103,19 +103,13 @@ serve-dev:
$(MAKE) P="serve-react serve-python-dev" make-p $(MAKE) P="serve-react serve-python-dev" make-p
test-e2e: init-db test-e2e: init-db
$(PYTEST) e2e --driver firefox $(PYTEST_ARGS) $(E2E_ARGS) $(PYTEST) e2e --driver firefox $(PYTEST_ARGS)
test-e2e-client: init-db test-e2e-client: init-db
E2E_ARGS=client $(PYTEST) e2e --driver firefox $(PYTEST_ARGS) E2E_ARGS=client $(PYTEST) e2e --driver firefox $(PYTEST_ARGS)
test-python: test-python:
$(PYTEST) fittrackee_api --cov-config .coveragerc --cov=fittrackee_api --cov-report term-missing $(PYTEST_ARGS) $(PYTEST) fittrackee --cov-config .coveragerc --cov=fittrackee --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
upgrade-db: upgrade-db:
$(FLASK) db upgrade --directory $(MIGRATIONS) $(FLASK) db upgrade --directory $(MIGRATIONS)

View File

@ -2,14 +2,14 @@ HOST = 0.0.0.0
API_PORT = 5000 API_PORT = 5000
CLIENT_PORT = 3000 CLIENT_PORT = 3000
export FLASK_APP = $(PWD)/fittrackee_api/server.py export FLASK_APP = $(PWD)/fittrackee/server.py
export APP_SETTINGS=fittrackee_api.config.DevelopmentConfig export APP_SETTINGS=fittrackee.config.DevelopmentConfig
export FLASK_ENV=development export FLASK_ENV=development
export TEST_APP_URL = http://$(HOST):$(API_PORT) export TEST_APP_URL = http://$(HOST):$(API_PORT)
export TEST_CLIENT_URL = http://$(HOST):$(CLIENT_PORT) export TEST_CLIENT_URL = http://$(HOST):$(CLIENT_PORT)
export DATABASE_URL = postgres://fittrackee:fittrackee@$(HOST):5432/fittrackee export DATABASE_URL = postgres://fittrackee:fittrackee@$(HOST):5432/fittrackee
export DATABASE_TEST_URL = postgres://fittrackee:fittrackee@$(HOST):5432/fittrackee_test 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 env
PYTHON_VERSION ?= python PYTHON_VERSION ?= python
@ -19,7 +19,6 @@ POETRY = poetry
FLASK = $(VENV)/bin/flask FLASK = $(VENV)/bin/flask
PYTEST = $(VENV)/bin/py.test -c pyproject.toml -W ignore::DeprecationWarning PYTEST = $(VENV)/bin/py.test -c pyproject.toml -W ignore::DeprecationWarning
GUNICORN = $(VENV)/bin/gunicorn GUNICORN = $(VENV)/bin/gunicorn
COV = $(VENV)/bin/python-codacy-coverage
BLACK = $(VENV)/bin/black BLACK = $(VENV)/bin/black
# Node env # Node env

View File

@ -1,7 +1,7 @@
Activities Activities
########## ##########
.. autoflask:: fittrackee_api:create_app() .. autoflask:: fittrackee:create_app()
:endpoints: :endpoints:
activities.get_activities, activities.get_activities,
activities.get_activity, activities.get_activity,

View File

@ -1,7 +1,7 @@
Authentication Authentication
############## ##############
.. autoflask:: fittrackee_api:create_app() .. autoflask:: fittrackee:create_app()
:endpoints: :endpoints:
auth.register_user, auth.register_user,
auth.login_user, auth.login_user,

View File

@ -1,7 +1,7 @@
Configuration Configuration
############# #############
.. autoflask:: fittrackee_api:create_app() .. autoflask:: fittrackee:create_app()
:endpoints: :endpoints:
config.get_application_config, config.get_application_config,
config.update_application_config, config.update_application_config,

View File

@ -1,6 +1,6 @@
Records Records
####### #######
.. autoflask:: fittrackee_api:create_app() .. autoflask:: fittrackee:create_app()
:endpoints: :endpoints:
records.get_records records.get_records

View File

@ -1,7 +1,7 @@
Sports Sports
###### ######
.. autoflask:: fittrackee_api:create_app() .. autoflask:: fittrackee:create_app()
:endpoints: :endpoints:
sports.get_sports, sports.get_sports,
sports.get_sport, sports.get_sport,

View File

@ -1,7 +1,7 @@
Statistics Statistics
########## ##########
.. autoflask:: fittrackee_api:create_app() .. autoflask:: fittrackee:create_app()
:endpoints: :endpoints:
stats.get_activities_by_time, stats.get_activities_by_time,
stats.get_activities_by_sport, stats.get_activities_by_sport,

View File

@ -1,7 +1,7 @@
Users Users
##### #####
.. autoflask:: fittrackee_api:create_app() .. autoflask:: fittrackee:create_app()
:endpoints: :endpoints:
users.get_users, users.get_users,
users.get_single_user, users.get_single_user,

View File

@ -144,7 +144,7 @@ Upgrade
.. warning:: .. warning::
| Before upgrading, make a backup of all data: | Before upgrading, make a backup of all data:
| - database (with `pg_dump <https://www.postgresql.org/docs/11/app-pgdump.html>`__ for instance) | - 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 Dev environment

View File

@ -293,7 +293,7 @@ password</p>
<div class="line-block"> <div class="line-block">
<div class="line">Before upgrading, make a backup of all data:</div> <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">- 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> </div>
<div class="section" id="id2"> <div class="section" id="id2">

View File

@ -1,7 +1,7 @@
Activities Activities
########## ##########
.. autoflask:: fittrackee_api:create_app() .. autoflask:: fittrackee:create_app()
:endpoints: :endpoints:
activities.get_activities, activities.get_activities,
activities.get_activity, activities.get_activity,

View File

@ -1,7 +1,7 @@
Authentication Authentication
############## ##############
.. autoflask:: fittrackee_api:create_app() .. autoflask:: fittrackee:create_app()
:endpoints: :endpoints:
auth.register_user, auth.register_user,
auth.login_user, auth.login_user,

View File

@ -1,7 +1,7 @@
Configuration Configuration
############# #############
.. autoflask:: fittrackee_api:create_app() .. autoflask:: fittrackee:create_app()
:endpoints: :endpoints:
config.get_application_config, config.get_application_config,
config.update_application_config, config.update_application_config,

View File

@ -1,6 +1,6 @@
Records Records
####### #######
.. autoflask:: fittrackee_api:create_app() .. autoflask:: fittrackee:create_app()
:endpoints: :endpoints:
records.get_records records.get_records

View File

@ -1,7 +1,7 @@
Sports Sports
###### ######
.. autoflask:: fittrackee_api:create_app() .. autoflask:: fittrackee:create_app()
:endpoints: :endpoints:
sports.get_sports, sports.get_sports,
sports.get_sport, sports.get_sport,

View File

@ -1,7 +1,7 @@
Statistics Statistics
########## ##########
.. autoflask:: fittrackee_api:create_app() .. autoflask:: fittrackee:create_app()
:endpoints: :endpoints:
stats.get_activities_by_time, stats.get_activities_by_time,
stats.get_activities_by_sport, stats.get_activities_by_sport,

View File

@ -1,7 +1,7 @@
Users Users
##### #####
.. autoflask:: fittrackee_api:create_app() .. autoflask:: fittrackee:create_app()
:endpoints: :endpoints:
users.get_users, users.get_users,
users.get_single_user, users.get_single_user,

View File

@ -16,7 +16,7 @@ from pathlib import Path
import sphinx_bootstrap_theme import sphinx_bootstrap_theme
sys.path.insert(0, os.path.abspath('../../fittrackee_api')) sys.path.insert(0, os.path.abspath('../../fittrackee'))
def setup(app): def setup(app):

View File

@ -144,7 +144,7 @@ Upgrade
.. warning:: .. warning::
| Before upgrading, make a backup of all data: | Before upgrading, make a backup of all data:
| - database (with `pg_dump <https://www.postgresql.org/docs/11/app-pgdump.html>`__ for instance) | - 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 Dev environment

View File

@ -15,21 +15,19 @@ bcrypt = Bcrypt()
migrate = Migrate() migrate = Migrate()
email_service = Email() email_service = Email()
dramatiq = Dramatiq() dramatiq = Dramatiq()
appLog = logging.getLogger('fittrackee_api') appLog = logging.getLogger('fittrackee')
def create_app(): def create_app():
# instantiate the app # instantiate the app
app = Flask( app = Flask(__name__, static_folder='dist/static', template_folder='dist')
__name__, static_folder='../dist/static', template_folder='../dist'
)
# set config # set config
with app.app_context(): with app.app_context():
app_settings = os.getenv('APP_SETTINGS') app_settings = os.getenv('APP_SETTINGS')
if app_settings == 'fittrackee_api.config.TestingConfig': if app_settings == 'fittrackee.config.TestingConfig':
# reload config on tests # reload config on tests
config = import_module('fittrackee_api.config') config = import_module('fittrackee.config')
reload(config) reload(config)
app.config.from_object(app_settings) app.config.from_object(app_settings)

View File

@ -4,7 +4,7 @@ import shutil
from datetime import datetime, timedelta from datetime import datetime, timedelta
import requests 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 flask import Blueprint, Response, current_app, jsonify, request, send_file
from sqlalchemy import exc from sqlalchemy import exc

View File

@ -1,7 +1,7 @@
import datetime import datetime
import os import os
from fittrackee_api import db from fittrackee 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,4 +1,4 @@
from fittrackee_api import appLog, db from fittrackee import appLog, db
from flask import Blueprint, jsonify, request from flask import Blueprint, jsonify, request
from sqlalchemy import exc from sqlalchemy import exc

View File

@ -1,6 +1,6 @@
from datetime import datetime, timedelta from datetime import datetime, timedelta
from fittrackee_api import appLog, db from fittrackee import appLog, db
from flask import Blueprint, jsonify, request from flask import Blueprint, jsonify, request
from sqlalchemy import func from sqlalchemy import func

View File

@ -6,7 +6,7 @@ from datetime import datetime, timedelta
import gpxpy.gpx import gpxpy.gpx
import pytz import pytz
from fittrackee_api import appLog, db from fittrackee import appLog, db
from flask import current_app from flask import current_app
from sqlalchemy import exc from sqlalchemy import exc
from staticmap import Line, StaticMap from staticmap import Line, StaticMap

View File

@ -2,7 +2,7 @@ import os
import forecastio import forecastio
import pytz import pytz
from fittrackee_api import appLog from fittrackee import appLog
API_KEY = os.getenv('WEATHER_API') API_KEY = os.getenv('WEATHER_API')

View File

@ -1,4 +1,4 @@
from fittrackee_api import appLog, db from fittrackee import appLog, db
from flask import Blueprint, current_app, jsonify, request from flask import Blueprint, current_app, jsonify, request
from sqlalchemy.orm.exc import MultipleResultsFound, NoResultFound from sqlalchemy.orm.exc import MultipleResultsFound, NoResultFound

View File

@ -1,4 +1,4 @@
from fittrackee_api import db from fittrackee import db
from flask import current_app from flask import current_app
from sqlalchemy.event import listens_for from sqlalchemy.event import listens_for

View File

@ -1,7 +1,7 @@
import os import os
from fittrackee_api import db from fittrackee import db
from fittrackee_api.users.models import User from fittrackee.users.models import User
from .models import AppConfig from .models import AppConfig

View File

@ -4,7 +4,7 @@ from dramatiq.brokers.redis import RedisBroker
from dramatiq.brokers.stub import StubBroker from dramatiq.brokers.stub import StubBroker
from flask import current_app from flask import current_app
if os.getenv('APP_SETTINGS') == 'fittrackee_api.config.TestingConfig': if os.getenv('APP_SETTINGS') == 'fittrackee.config.TestingConfig':
broker = StubBroker broker = StubBroker
else: else:
broker = RedisBroker broker = RedisBroker

View File

Before

Width:  |  Height:  |  Size: 318 B

After

Width:  |  Height:  |  Size: 318 B

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1012 B

After

Width:  |  Height:  |  Size: 1012 B

View File

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 637 B

After

Width:  |  Height:  |  Size: 637 B

View File

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Some files were not shown because too many files have changed in this diff Show More