mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
Codestyle enhancements
This commit is contained in:
parent
0a8b32e57e
commit
7362bb5514
@ -1,6 +1,7 @@
|
||||
from config import Config
|
||||
from flask import Flask
|
||||
from flask_apscheduler import APScheduler
|
||||
from flask_assets import Environment
|
||||
from flask_login import LoginManager
|
||||
from flask_mail import Mail
|
||||
from flask_migrate import Migrate
|
||||
@ -8,10 +9,9 @@ from flask_paranoid import Paranoid
|
||||
from flask_socketio import SocketIO
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from flask_hashids import Hashids
|
||||
import flask_assets
|
||||
|
||||
|
||||
assets: flask_assets.Environment = flask_assets.Environment()
|
||||
assets: Environment = Environment()
|
||||
db: SQLAlchemy = SQLAlchemy()
|
||||
hashids: Hashids = Hashids()
|
||||
login: LoginManager = LoginManager()
|
||||
@ -38,10 +38,7 @@ def create_app(config: Config = Config) -> Flask:
|
||||
mail.init_app(app)
|
||||
migrate.init_app(app, db)
|
||||
paranoid.init_app(app)
|
||||
socketio.init_app(
|
||||
app,
|
||||
message_queue=app.config['NOPAQUE_SOCKETIO_MESSAGE_QUEUE_URI']
|
||||
)
|
||||
socketio.init_app(app, message_queue=app.config['NOPAQUE_SOCKETIO_MESSAGE_QUEUE_URI']) # noqa
|
||||
|
||||
from app import socketio_event_listeners
|
||||
from app import sqlalchemy_event_listeners
|
||||
|
@ -869,7 +869,7 @@ class Corpus(HashidMixin, db.Model):
|
||||
cascade='all, delete-orphan'
|
||||
)
|
||||
# "static" attributes
|
||||
max_num_tokens = 2147483647
|
||||
max_num_tokens = 2_147_483_647
|
||||
|
||||
def __repr__(self):
|
||||
return f'<Corpus {self.title}>'
|
||||
|
@ -1,6 +1,6 @@
|
||||
from app import hashids, socketio
|
||||
from app.decorators import socketio_login_required
|
||||
from app.models import User
|
||||
from app.models import TesseractOCRModel, TranskribusHTRModel, User
|
||||
from flask_login import current_user
|
||||
from flask_socketio import join_room
|
||||
|
||||
@ -11,14 +11,31 @@ def users_user_get(user_hashid):
|
||||
user_id = hashids.decode(user_hashid)
|
||||
user = User.query.get(user_id)
|
||||
if user is None:
|
||||
response = {'code': 404, 'msg': 'Not found'}
|
||||
elif not (user == current_user or current_user.is_administrator):
|
||||
response = {'code': 403, 'msg': 'Forbidden'}
|
||||
else:
|
||||
response = {
|
||||
'code': 200,
|
||||
'msg': 'OK',
|
||||
'payload': user.to_dict(backrefs=True, relationships=True)
|
||||
}
|
||||
join_room(f'users.{user.hashid}')
|
||||
return response
|
||||
return {'code': 404, 'msg': 'Not found'}
|
||||
if not (user == current_user or current_user.is_administrator):
|
||||
return {'code': 403, 'msg': 'Forbidden'}
|
||||
# corpora = [x.to_dict() for x in user.corpora]
|
||||
# jobs = [x.to_dict() for x in user.jobs]
|
||||
# transkribus_htr_models = TranskribusHTRModel.query.filter(
|
||||
# (TranskribusHTRModel.shared == True) | (TranskribusHTRModel.user == user)
|
||||
# ).all()
|
||||
# tesseract_ocr_models = TesseractOCRModel.query.filter(
|
||||
# (TesseractOCRModel.shared == True) | (TesseractOCRModel.user == user)
|
||||
# ).all()
|
||||
# response = {
|
||||
# 'code': 200,
|
||||
# 'msg': 'OK',
|
||||
# 'payload': {
|
||||
# 'user': user.to_dict(),
|
||||
# 'corpora': corpora,
|
||||
# 'jobs': jobs,
|
||||
# 'transkribus_htr_models': transkribus_htr_models,
|
||||
# 'tesseract_ocr_models': tesseract_ocr_models
|
||||
# }
|
||||
# }
|
||||
join_room(f'users.{user.hashid}')
|
||||
return {
|
||||
'code': 200,
|
||||
'msg': 'OK',
|
||||
'payload': user.to_dict(backrefs=True, relationships=True)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user