Skip to content

Commit

Permalink
use CODE_APPLICATION instead of ID_APP
Browse files Browse the repository at this point in the history
  • Loading branch information
bouttier committed Nov 22, 2022
1 parent 038c0ba commit a9be041
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
14 changes: 3 additions & 11 deletions apptax/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,10 @@ def create_app():
app.config["S3_FOLDER"] = app.config.get("S3_FOLDER", None)
app.config["S3_REGION_NAME"] = app.config.get("S3_REGION_NAME", None)

with app.app_context():
try:
from pypnusershub.db.models import Application

th_app = Application.query.filter_by(code_application="TH").one()
except (OperationalError, ProgrammingError, NoResultFound):
logging.warning(
"Warning: unable to find TaxHub application, database not yet initialized?"
)
else:
app.config["ID_APP"] = th_app.id_application
if "CODE_APPLICATION" not in app.config:
app.config["CODE_APPLICATION"] = "TH"

with app.app_context():
from pypnusershub import routes

app.register_blueprint(routes.routes, url_prefix="/api/auth")
Expand Down
2 changes: 1 addition & 1 deletion apptax/tests/test_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

@pytest.fixture
def user():
a = Application.query.get(current_app.config["ID_APP"])
a = Application.query.filter_by(code_application=current_app.config["CODE_APPLICATION"]).one()
p = (
Profils.query.filter(Profils.applications.contains(a))
.filter(Profils.id_profil >= 2) # level >= 2
Expand Down
6 changes: 5 additions & 1 deletion apptax/utils/routesconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ def get_config(id=None):
Route générant la configuration utile au frontend
"""

data = db.session.query(Application).filter_by(code_application="TH").first()
data = (
db.session.query(Application)
.filter_by(code_application=current_app.config["CODE_APPLICATION"])
.first()
)

return {"id_application": data.id_application}

0 comments on commit a9be041

Please sign in to comment.