diff --git a/app/__init__.py b/app/__init__.py index 4a9b0652..50f946be 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -75,9 +75,9 @@ def create_app(config: Config = Config) -> Flask: from .corpora import bp as corpora_blueprint from .corpora.cqi_over_sio import CQiNamespace - socketio.on_namespace(CQiNamespace('/cqi_over_sio')) default_breadcrumb_root(corpora_blueprint, '.corpora') app.register_blueprint(corpora_blueprint, cli_group='corpus', url_prefix='/corpora') + socketio.on_namespace(CQiNamespace('/cqi_over_sio')) from .errors import bp as errors_bp app.register_blueprint(errors_bp) diff --git a/app/static/js/App.js b/app/static/js/App.js index 0741592d..cfcb3a05 100644 --- a/app/static/js/App.js +++ b/app/static/js/App.js @@ -8,19 +8,19 @@ class App { this.socket.on('PATCH', (patch) => {this.onPatch(patch);}); } - getUser(userId, backrefs=true, relationships=true) { + getUser(userId) { if (userId in this.data.promises.getUser) { return this.data.promises.getUser[userId]; } this.data.promises.getUser[userId] = new Promise((resolve, reject) => { - this.socket.emit('GET /users/', userId, backrefs, relationships, (response) => { - if (response.status !== 200) { - reject(response); - return; + this.socket.emit('GET /users/', userId, (response) => { + if (response.status === 200) { + this.data.users[userId] = response.body; + resolve(this.data.users[userId]); + } else { + reject(`[${response.status}] ${response.statusText}`); } - this.data.users[userId] = response.body; - resolve(this.data.users[userId]); }); }); diff --git a/app/users/events.py b/app/users/events.py index af490a01..5f59e394 100644 --- a/app/users/events.py +++ b/app/users/events.py @@ -7,7 +7,7 @@ from app.models import User @socketio.on('GET /users/') @socketio_login_required -def get_user(user_hashid, backrefs=False, relationships=False): +def get_user(user_hashid): user_id = hashids.decode(user_hashid) user = User.query.get(user_id) if user is None: @@ -15,12 +15,9 @@ def get_user(user_hashid, backrefs=False, relationships=False): if not (user == current_user or current_user.is_administrator()): return {'status': 403, 'statusText': 'Forbidden'} return { - 'body': user.to_json_serializeable( - backrefs=backrefs, - relationships=relationships - ), + 'body': user.to_json_serializeable(backrefs=True, relationships=True), 'status': 200, - 'statusText': 'OK', + 'statusText': 'OK' }