| 1234567891011121314151617181920212223 | from flask_login import current_userfrom werkzeug.exceptions import NotFoundfrom controllers.console.app.error import AppUnavailableErrorfrom extensions.ext_database import dbfrom models.model import Appdef _get_app(app_id, mode=None):    app = db.session.query(App).filter(        App.id == app_id,        App.tenant_id == current_user.current_tenant_id,        App.status == 'normal'    ).first()    if not app:        raise NotFound("App not found")    if mode and app.mode != mode:        raise NotFound("The {} app not found".format(mode))    return app
 |