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_migrate import upgrade
|
||||
import click
|
||||
import os
|
||||
from app.models import Role, User, TesseractOCRModel, TranskribusHTRModel
|
||||
|
||||
|
||||
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 app.decorators import permission_required
|
||||
from app.models import Permission
|
||||
from . import bp
|
||||
|
||||
|
||||
@ -16,10 +12,5 @@ def before_request():
|
||||
|
||||
|
||||
@bp.route('')
|
||||
def index():
|
||||
pass
|
||||
|
||||
|
||||
@bp.route('/tesseract_ocr_model', methods=['GET', 'POST'])
|
||||
def tesseract_ocr_model():
|
||||
def contributions():
|
||||
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_login import current_user
|
||||
from flask_socketio import ConnectionRefusedError
|
||||
from threading import Lock
|
||||
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.decorators import socketio_login_required
|
||||
from socket import gaierror
|
||||
from . import NAMESPACE as ns
|
||||
from .utils import cqi_over_socketio
|
||||
import cqi
|
||||
|
||||
|
||||
@socketio.on('cqi.connect', namespace=ns)
|
||||
|
@ -1,8 +1,8 @@
|
||||
import cqi
|
||||
from app import socketio
|
||||
from app.decorators import socketio_login_required
|
||||
from . import NAMESPACE as ns
|
||||
from .utils import cqi_over_socketio
|
||||
import cqi
|
||||
|
||||
|
||||
@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.decorators import socketio_login_required
|
||||
from app.models import Corpus
|
||||
from flask import session
|
||||
from . import NAMESPACE as ns
|
||||
from .utils import cqi_over_socketio, lookups_by_cpos
|
||||
import cqi
|
||||
import math
|
||||
|
||||
|
||||
@socketio.on('cqi.corpora.corpus.drop', namespace=ns)
|
||||
|
@ -1,8 +1,8 @@
|
||||
import cqi
|
||||
from app import socketio
|
||||
from app.decorators import socketio_login_required
|
||||
from . import NAMESPACE as ns
|
||||
from .utils import cqi_over_socketio
|
||||
import cqi
|
||||
|
||||
|
||||
@socketio.on('cqi.corpora.corpus.alignment_attributes.get', namespace=ns)
|
||||
|
@ -1,8 +1,8 @@
|
||||
import cqi
|
||||
from app import socketio
|
||||
from app.decorators import socketio_login_required
|
||||
from . import NAMESPACE as ns
|
||||
from .utils import cqi_over_socketio
|
||||
import cqi
|
||||
|
||||
|
||||
@socketio.on('cqi.corpora.corpus.positional_attributes.get', namespace=ns)
|
||||
|
@ -1,8 +1,8 @@
|
||||
import cqi
|
||||
from app import socketio
|
||||
from app.decorators import socketio_login_required
|
||||
from . import NAMESPACE as ns
|
||||
from .utils import cqi_over_socketio
|
||||
import cqi
|
||||
|
||||
|
||||
@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 . import NAMESPACE as ns
|
||||
from .utils import cqi_over_socketio, export_subcorpus
|
||||
import cqi
|
||||
import json
|
||||
import math
|
||||
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)
|
||||
|
@ -1,8 +1,8 @@
|
||||
from app.models import Permission
|
||||
from flask import abort, current_app
|
||||
from flask_login import current_user
|
||||
from functools import wraps
|
||||
from threading import Thread
|
||||
from app.models import Permission
|
||||
|
||||
|
||||
def permission_required(permission):
|
||||
|
12
app/email.py
12
app/email.py
@ -1,11 +1,10 @@
|
||||
from app import mail
|
||||
from flask import current_app, Flask, render_template
|
||||
from flask import current_app, render_template
|
||||
from flask_mail import Message
|
||||
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']
|
||||
msg: Message = Message(
|
||||
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
|
||||
|
||||
|
||||
def _send(app: Flask, msg):
|
||||
def send(msg, *args, **kwargs):
|
||||
def _send(app, 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.start()
|
||||
return thread
|
||||
|
Loading…
Reference in New Issue
Block a user