mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 02:44:18 +00:00
Restructure imports (3rd party imports first)
This commit is contained in:
parent
8f03c2aea7
commit
ec9225b881
@ -1,8 +1,8 @@
|
|||||||
from app.models import Role, User, TesseractOCRModel, TranskribusHTRModel
|
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
from flask_migrate import upgrade
|
from flask_migrate import upgrade
|
||||||
import click
|
import click
|
||||||
import os
|
import os
|
||||||
|
from app.models import Role, User, TesseractOCRModel, TranskribusHTRModel
|
||||||
|
|
||||||
|
|
||||||
def _make_default_dirs():
|
def _make_default_dirs():
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
from ast import Pass
|
|
||||||
from app import db
|
|
||||||
from app.decorators import permission_required
|
|
||||||
from app.models import Permission, Role, User
|
|
||||||
from app.settings import tasks as settings_tasks
|
|
||||||
from flask import flash, redirect, render_template, url_for
|
|
||||||
from flask_login import login_required
|
from flask_login import login_required
|
||||||
|
from app.decorators import permission_required
|
||||||
|
from app.models import Permission
|
||||||
from . import bp
|
from . import bp
|
||||||
|
|
||||||
|
|
||||||
@ -16,10 +12,5 @@ def before_request():
|
|||||||
|
|
||||||
|
|
||||||
@bp.route('')
|
@bp.route('')
|
||||||
def index():
|
def contributions():
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/tesseract_ocr_model', methods=['GET', 'POST'])
|
|
||||||
def tesseract_ocr_model():
|
|
||||||
pass
|
pass
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
from app import db, hashids, socketio
|
|
||||||
from app.decorators import socketio_login_required
|
|
||||||
from app.models import Corpus, CorpusStatus
|
|
||||||
from flask import session
|
from flask import session
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
from flask_socketio import ConnectionRefusedError
|
from flask_socketio import ConnectionRefusedError
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
import cqi
|
import cqi
|
||||||
|
from app import db, hashids, socketio
|
||||||
|
from app.decorators import socketio_login_required
|
||||||
|
from app.models import Corpus, CorpusStatus
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
|
from socket import gaierror
|
||||||
|
import cqi
|
||||||
from app import socketio
|
from app import socketio
|
||||||
from app.decorators import socketio_login_required
|
from app.decorators import socketio_login_required
|
||||||
from socket import gaierror
|
|
||||||
from . import NAMESPACE as ns
|
from . import NAMESPACE as ns
|
||||||
from .utils import cqi_over_socketio
|
from .utils import cqi_over_socketio
|
||||||
import cqi
|
|
||||||
|
|
||||||
|
|
||||||
@socketio.on('cqi.connect', namespace=ns)
|
@socketio.on('cqi.connect', namespace=ns)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
|
import cqi
|
||||||
from app import socketio
|
from app import socketio
|
||||||
from app.decorators import socketio_login_required
|
from app.decorators import socketio_login_required
|
||||||
from . import NAMESPACE as ns
|
from . import NAMESPACE as ns
|
||||||
from .utils import cqi_over_socketio
|
from .utils import cqi_over_socketio
|
||||||
import cqi
|
|
||||||
|
|
||||||
|
|
||||||
@socketio.on('cqi.corpora.get', namespace=ns)
|
@socketio.on('cqi.corpora.get', namespace=ns)
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
|
from flask import session
|
||||||
|
import cqi
|
||||||
|
import math
|
||||||
from app import db, socketio
|
from app import db, socketio
|
||||||
from app.decorators import socketio_login_required
|
from app.decorators import socketio_login_required
|
||||||
from app.models import Corpus
|
from app.models import Corpus
|
||||||
from flask import session
|
|
||||||
from . import NAMESPACE as ns
|
from . import NAMESPACE as ns
|
||||||
from .utils import cqi_over_socketio, lookups_by_cpos
|
from .utils import cqi_over_socketio, lookups_by_cpos
|
||||||
import cqi
|
|
||||||
import math
|
|
||||||
|
|
||||||
|
|
||||||
@socketio.on('cqi.corpora.corpus.drop', namespace=ns)
|
@socketio.on('cqi.corpora.corpus.drop', namespace=ns)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
|
import cqi
|
||||||
from app import socketio
|
from app import socketio
|
||||||
from app.decorators import socketio_login_required
|
from app.decorators import socketio_login_required
|
||||||
from . import NAMESPACE as ns
|
from . import NAMESPACE as ns
|
||||||
from .utils import cqi_over_socketio
|
from .utils import cqi_over_socketio
|
||||||
import cqi
|
|
||||||
|
|
||||||
|
|
||||||
@socketio.on('cqi.corpora.corpus.alignment_attributes.get', namespace=ns)
|
@socketio.on('cqi.corpora.corpus.alignment_attributes.get', namespace=ns)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
|
import cqi
|
||||||
from app import socketio
|
from app import socketio
|
||||||
from app.decorators import socketio_login_required
|
from app.decorators import socketio_login_required
|
||||||
from . import NAMESPACE as ns
|
from . import NAMESPACE as ns
|
||||||
from .utils import cqi_over_socketio
|
from .utils import cqi_over_socketio
|
||||||
import cqi
|
|
||||||
|
|
||||||
|
|
||||||
@socketio.on('cqi.corpora.corpus.positional_attributes.get', namespace=ns)
|
@socketio.on('cqi.corpora.corpus.positional_attributes.get', namespace=ns)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
|
import cqi
|
||||||
from app import socketio
|
from app import socketio
|
||||||
from app.decorators import socketio_login_required
|
from app.decorators import socketio_login_required
|
||||||
from . import NAMESPACE as ns
|
from . import NAMESPACE as ns
|
||||||
from .utils import cqi_over_socketio
|
from .utils import cqi_over_socketio
|
||||||
import cqi
|
|
||||||
|
|
||||||
|
|
||||||
@socketio.on('cqi.corpora.corpus.structural_attributes.get', namespace=ns)
|
@socketio.on('cqi.corpora.corpus.structural_attributes.get', namespace=ns)
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
from app import socketio
|
|
||||||
from app.decorators import socketio_login_required
|
|
||||||
from app.models import Corpus
|
|
||||||
from flask import session
|
from flask import session
|
||||||
from . import NAMESPACE as ns
|
|
||||||
from .utils import cqi_over_socketio, export_subcorpus
|
|
||||||
import cqi
|
import cqi
|
||||||
import json
|
import json
|
||||||
import math
|
import math
|
||||||
import os
|
import os
|
||||||
|
from app import socketio
|
||||||
|
from app.decorators import socketio_login_required
|
||||||
|
from app.models import Corpus
|
||||||
|
from . import NAMESPACE as ns
|
||||||
|
from .utils import cqi_over_socketio, export_subcorpus
|
||||||
|
|
||||||
|
|
||||||
@socketio.on('cqi.corpora.corpus.subcorpora.get', namespace=ns)
|
@socketio.on('cqi.corpora.corpus.subcorpora.get', namespace=ns)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
from app.models import Permission
|
|
||||||
from flask import abort, current_app
|
from flask import abort, current_app
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
from app.models import Permission
|
||||||
|
|
||||||
|
|
||||||
def permission_required(permission):
|
def permission_required(permission):
|
||||||
|
16
app/email.py
16
app/email.py
@ -1,11 +1,10 @@
|
|||||||
from app import mail
|
from flask import current_app, render_template
|
||||||
from flask import current_app, Flask, render_template
|
|
||||||
from flask_mail import Message
|
from flask_mail import Message
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from typing import Any
|
from app import mail
|
||||||
|
|
||||||
|
|
||||||
def create_message(recipient: str, subject: str, template: str, **kwargs: Any) -> Message:
|
def create_message(recipient, subject, template, **kwargs):
|
||||||
subject_prefix: str = current_app.config['NOPAQUE_MAIL_SUBJECT_PREFIX']
|
subject_prefix: str = current_app.config['NOPAQUE_MAIL_SUBJECT_PREFIX']
|
||||||
msg: Message = Message(
|
msg: Message = Message(
|
||||||
body=render_template(f'{template}.txt.j2', **kwargs),
|
body=render_template(f'{template}.txt.j2', **kwargs),
|
||||||
@ -16,12 +15,11 @@ def create_message(recipient: str, subject: str, template: str, **kwargs: Any) -
|
|||||||
return msg
|
return msg
|
||||||
|
|
||||||
|
|
||||||
def _send(app: Flask, msg):
|
def send(msg, *args, **kwargs):
|
||||||
with app.app_context():
|
def _send(app, msg):
|
||||||
mail.send(msg)
|
with app.app_context():
|
||||||
|
mail.send(msg)
|
||||||
|
|
||||||
|
|
||||||
def send(msg: Message, *args, **kwargs):
|
|
||||||
thread = Thread(target=_send, args=[current_app._get_current_object(), msg])
|
thread = Thread(target=_send, args=[current_app._get_current_object(), msg])
|
||||||
thread.start()
|
thread.start()
|
||||||
return thread
|
return thread
|
||||||
|
Loading…
Reference in New Issue
Block a user