mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-04 04:12:45 +00:00 
			
		
		
		
	flatten the contributions blueprint
This commit is contained in:
		@@ -15,9 +15,4 @@ def before_request():
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
from . import (
 | 
			
		||||
    routes,
 | 
			
		||||
    spacy_nlp_pipeline_models,
 | 
			
		||||
    tesseract_ocr_pipeline_models,
 | 
			
		||||
    transkribus_htr_pipeline_models
 | 
			
		||||
)
 | 
			
		||||
from . import routes
 | 
			
		||||
 
 | 
			
		||||
@@ -3,5 +3,5 @@ from . import bp
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@bp.route('')
 | 
			
		||||
def contributions():
 | 
			
		||||
def index():
 | 
			
		||||
    return redirect(url_for('main.dashboard', _anchor='contributions'))
 | 
			
		||||
 
 | 
			
		||||
@@ -1,2 +0,0 @@
 | 
			
		||||
from .. import bp
 | 
			
		||||
from . import json_routes, routes
 | 
			
		||||
@@ -1,2 +0,0 @@
 | 
			
		||||
from .. import bp
 | 
			
		||||
from . import json_routes, routes
 | 
			
		||||
@@ -1,2 +0,0 @@
 | 
			
		||||
from .. import bp
 | 
			
		||||
from . import routes
 | 
			
		||||
							
								
								
									
										18
									
								
								app/blueprints/spacy_nlp_pipeline_models/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								app/blueprints/spacy_nlp_pipeline_models/__init__.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
from flask import current_app, Blueprint
 | 
			
		||||
from flask_login import login_required
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
bp = Blueprint('spacy_nlp_pipeline_models', __name__)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@bp.before_request
 | 
			
		||||
@login_required
 | 
			
		||||
def before_request():
 | 
			
		||||
    '''
 | 
			
		||||
    Ensures that the routes in this package can only be visited by users that
 | 
			
		||||
    are logged in.
 | 
			
		||||
    '''
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
from . import routes, json_routes
 | 
			
		||||
@@ -1,8 +1,8 @@
 | 
			
		||||
from flask_wtf.file import FileField, FileRequired
 | 
			
		||||
from wtforms import StringField, ValidationError
 | 
			
		||||
from wtforms.validators import InputRequired, Length
 | 
			
		||||
from app.blueprints.contributions.forms import ContributionBaseForm, UpdateContributionBaseForm
 | 
			
		||||
from app.blueprints.services import SERVICES
 | 
			
		||||
from ..forms import ContributionBaseForm, UpdateContributionBaseForm
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CreateSpaCyNLPPipelineModelForm(ContributionBaseForm):
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
from flask import abort, current_app, request
 | 
			
		||||
from flask_login import current_user
 | 
			
		||||
from flask_login import current_user, login_required
 | 
			
		||||
from threading import Thread
 | 
			
		||||
from app import db
 | 
			
		||||
from app.decorators import content_negotiation, permission_required
 | 
			
		||||
@@ -7,7 +7,8 @@ from app.models import SpaCyNLPPipelineModel
 | 
			
		||||
from . import bp
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@bp.route('/spacy-nlp-pipeline-models/<hashid:spacy_nlp_pipeline_model_id>', methods=['DELETE'])
 | 
			
		||||
@bp.route('/<hashid:spacy_nlp_pipeline_model_id>', methods=['DELETE'])
 | 
			
		||||
@login_required
 | 
			
		||||
@content_negotiation(produces='application/json')
 | 
			
		||||
def delete_spacy_model(spacy_nlp_pipeline_model_id):
 | 
			
		||||
    def _delete_spacy_model(app, spacy_nlp_pipeline_model_id):
 | 
			
		||||
@@ -15,7 +16,7 @@ def delete_spacy_model(spacy_nlp_pipeline_model_id):
 | 
			
		||||
            snpm = SpaCyNLPPipelineModel.query.get(spacy_nlp_pipeline_model_id)
 | 
			
		||||
            snpm.delete()
 | 
			
		||||
            db.session.commit()
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    snpm = SpaCyNLPPipelineModel.query.get_or_404(spacy_nlp_pipeline_model_id)
 | 
			
		||||
    if not (snpm.user == current_user or current_user.is_administrator):
 | 
			
		||||
        abort(403)
 | 
			
		||||
@@ -31,7 +32,7 @@ def delete_spacy_model(spacy_nlp_pipeline_model_id):
 | 
			
		||||
    return response_data, 202
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@bp.route('/spacy-nlp-pipeline-models/<hashid:spacy_nlp_pipeline_model_id>/is_public', methods=['PUT'])
 | 
			
		||||
@bp.route('/<hashid:spacy_nlp_pipeline_model_id>/is_public', methods=['PUT'])
 | 
			
		||||
@permission_required('CONTRIBUTE')
 | 
			
		||||
@content_negotiation(consumes='application/json', produces='application/json')
 | 
			
		||||
def update_spacy_nlp_pipeline_model_is_public(spacy_nlp_pipeline_model_id):
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
from flask import abort, flash, redirect, render_template, url_for
 | 
			
		||||
from flask_login import current_user
 | 
			
		||||
from flask_login import current_user, login_required
 | 
			
		||||
from app import db
 | 
			
		||||
from app.models import SpaCyNLPPipelineModel
 | 
			
		||||
from . import bp
 | 
			
		||||
@@ -9,16 +9,18 @@ from .forms import (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@bp.route('/spacy-nlp-pipeline-models')
 | 
			
		||||
def spacy_nlp_pipeline_models():
 | 
			
		||||
@bp.route('/')
 | 
			
		||||
@login_required
 | 
			
		||||
def index():
 | 
			
		||||
    return render_template(
 | 
			
		||||
        'contributions/spacy_nlp_pipeline_models/spacy_nlp_pipeline_models.html.j2',
 | 
			
		||||
        'spacy_nlp_pipeline_models/index.html.j2',
 | 
			
		||||
        title='SpaCy NLP Pipeline Models'
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@bp.route('/spacy-nlp-pipeline-models/create', methods=['GET', 'POST'])
 | 
			
		||||
def create_spacy_nlp_pipeline_model():
 | 
			
		||||
@bp.route('/create', methods=['GET', 'POST'])
 | 
			
		||||
@login_required
 | 
			
		||||
def create():
 | 
			
		||||
    form = CreateSpaCyNLPPipelineModelForm()
 | 
			
		||||
    if form.is_submitted():
 | 
			
		||||
        if not form.validate():
 | 
			
		||||
@@ -42,15 +44,16 @@ def create_spacy_nlp_pipeline_model():
 | 
			
		||||
            abort(500)
 | 
			
		||||
        db.session.commit()
 | 
			
		||||
        flash(f'SpaCy NLP Pipeline model "{snpm.title}" created')
 | 
			
		||||
        return {}, 201, {'Location': url_for('.spacy_nlp_pipeline_models')}
 | 
			
		||||
        return {}, 201, {'Location': url_for('.index')}
 | 
			
		||||
    return render_template(
 | 
			
		||||
        'contributions/spacy_nlp_pipeline_models/create.html.j2',
 | 
			
		||||
        'spacy_nlp_pipeline_models/create.html.j2',
 | 
			
		||||
        title='Create SpaCy NLP Pipeline Model',
 | 
			
		||||
        form=form
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@bp.route('/spacy-nlp-pipeline-models/<hashid:spacy_nlp_pipeline_model_id>', methods=['GET', 'POST'])
 | 
			
		||||
@bp.route('/<hashid:spacy_nlp_pipeline_model_id>', methods=['GET', 'POST'])
 | 
			
		||||
@login_required
 | 
			
		||||
def spacy_nlp_pipeline_model(spacy_nlp_pipeline_model_id):
 | 
			
		||||
    snpm = SpaCyNLPPipelineModel.query.get_or_404(spacy_nlp_pipeline_model_id)
 | 
			
		||||
    if not (snpm.user == current_user or current_user.is_administrator):
 | 
			
		||||
@@ -61,9 +64,9 @@ def spacy_nlp_pipeline_model(spacy_nlp_pipeline_model_id):
 | 
			
		||||
        if db.session.is_modified(snpm):
 | 
			
		||||
            flash(f'SpaCy NLP Pipeline model "{snpm.title}" updated')
 | 
			
		||||
            db.session.commit()
 | 
			
		||||
        return redirect(url_for('.spacy_nlp_pipeline_models'))
 | 
			
		||||
        return redirect(url_for('.index'))
 | 
			
		||||
    return render_template(
 | 
			
		||||
        'contributions/spacy_nlp_pipeline_models/spacy_nlp_pipeline_model.html.j2',
 | 
			
		||||
        'spacy_nlp_pipeline_models/spacy_nlp_pipeline_model.html.j2',
 | 
			
		||||
        title=f'{snpm.title} {snpm.version}',
 | 
			
		||||
        form=form,
 | 
			
		||||
        spacy_nlp_pipeline_model=snpm
 | 
			
		||||
							
								
								
									
										18
									
								
								app/blueprints/tesseract_ocr_pipeline_models/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								app/blueprints/tesseract_ocr_pipeline_models/__init__.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
from flask import Blueprint
 | 
			
		||||
from flask_login import login_required
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
bp = Blueprint('tesseract_ocr_pipeline_models', __name__)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@bp.before_request
 | 
			
		||||
@login_required
 | 
			
		||||
def before_request():
 | 
			
		||||
    '''
 | 
			
		||||
    Ensures that the routes in this package can only be visited by users that
 | 
			
		||||
    are logged in.
 | 
			
		||||
    '''
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
from . import json_routes, routes
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
from flask_wtf.file import FileField, FileRequired
 | 
			
		||||
from wtforms import ValidationError
 | 
			
		||||
from app.blueprints.contributions.forms import ContributionBaseForm, UpdateContributionBaseForm
 | 
			
		||||
from app.blueprints.services import SERVICES
 | 
			
		||||
from ..forms import ContributionBaseForm, UpdateContributionBaseForm
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CreateTesseractOCRPipelineModelForm(ContributionBaseForm):
 | 
			
		||||
@@ -7,7 +7,7 @@ from app.models import TesseractOCRPipelineModel
 | 
			
		||||
from . import bp
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@bp.route('/tesseract-ocr-pipeline-models/<hashid:tesseract_ocr_pipeline_model_id>', methods=['DELETE'])
 | 
			
		||||
@bp.route('/<hashid:tesseract_ocr_pipeline_model_id>', methods=['DELETE'])
 | 
			
		||||
@content_negotiation(produces='application/json')
 | 
			
		||||
def delete_tesseract_model(tesseract_ocr_pipeline_model_id):
 | 
			
		||||
    def _delete_tesseract_ocr_pipeline_model(app, tesseract_ocr_pipeline_model_id):
 | 
			
		||||
@@ -31,7 +31,7 @@ def delete_tesseract_model(tesseract_ocr_pipeline_model_id):
 | 
			
		||||
    return response_data, 202
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@bp.route('/tesseract-ocr-pipeline-models/<hashid:tesseract_ocr_pipeline_model_id>/is_public', methods=['PUT'])
 | 
			
		||||
@bp.route('/<hashid:tesseract_ocr_pipeline_model_id>/is_public', methods=['PUT'])
 | 
			
		||||
@permission_required('CONTRIBUTE')
 | 
			
		||||
@content_negotiation(consumes='application/json', produces='application/json')
 | 
			
		||||
def update_tesseract_ocr_pipeline_model_is_public(tesseract_ocr_pipeline_model_id):
 | 
			
		||||
@@ -9,16 +9,16 @@ from .forms import (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@bp.route('/tesseract-ocr-pipeline-models')
 | 
			
		||||
def tesseract_ocr_pipeline_models():
 | 
			
		||||
@bp.route('/')
 | 
			
		||||
def index():
 | 
			
		||||
    return render_template(
 | 
			
		||||
        'contributions/tesseract_ocr_pipeline_models/tesseract_ocr_pipeline_models.html.j2',
 | 
			
		||||
        'tesseract_ocr_pipeline_models/index.html.j2',
 | 
			
		||||
        title='Tesseract OCR Pipeline Models'
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@bp.route('/tesseract-ocr-pipeline-models/create', methods=['GET', 'POST'])
 | 
			
		||||
def create_tesseract_ocr_pipeline_model():
 | 
			
		||||
@bp.route('/create', methods=['GET', 'POST'])
 | 
			
		||||
def create():
 | 
			
		||||
    form = CreateTesseractOCRPipelineModelForm()
 | 
			
		||||
    if form.is_submitted():
 | 
			
		||||
        if not form.validate():
 | 
			
		||||
@@ -41,15 +41,15 @@ def create_tesseract_ocr_pipeline_model():
 | 
			
		||||
            abort(500)
 | 
			
		||||
        db.session.commit()
 | 
			
		||||
        flash(f'Tesseract OCR Pipeline model "{topm.title}" created')
 | 
			
		||||
        return {}, 201, {'Location': url_for('.tesseract_ocr_pipeline_models')}
 | 
			
		||||
        return {}, 201, {'Location': url_for('.index')}
 | 
			
		||||
    return render_template(
 | 
			
		||||
        'contributions/tesseract_ocr_pipeline_models/create.html.j2',
 | 
			
		||||
        'tesseract_ocr_pipeline_models/create.html.j2',
 | 
			
		||||
        title='Create Tesseract OCR Pipeline Model',
 | 
			
		||||
        form=form
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@bp.route('/tesseract-ocr-pipeline-models/<hashid:tesseract_ocr_pipeline_model_id>', methods=['GET', 'POST'])
 | 
			
		||||
@bp.route('/<hashid:tesseract_ocr_pipeline_model_id>', methods=['GET', 'POST'])
 | 
			
		||||
def tesseract_ocr_pipeline_model(tesseract_ocr_pipeline_model_id):
 | 
			
		||||
    topm = TesseractOCRPipelineModel.query.get_or_404(tesseract_ocr_pipeline_model_id)
 | 
			
		||||
    if not (topm.user == current_user or current_user.is_administrator):
 | 
			
		||||
@@ -60,9 +60,9 @@ def tesseract_ocr_pipeline_model(tesseract_ocr_pipeline_model_id):
 | 
			
		||||
        if db.session.is_modified(topm):
 | 
			
		||||
            flash(f'Tesseract OCR Pipeline model "{topm.title}" updated')
 | 
			
		||||
            db.session.commit()
 | 
			
		||||
        return redirect(url_for('.tesseract_ocr_pipeline_models'))
 | 
			
		||||
        return redirect(url_for('.index'))
 | 
			
		||||
    return render_template(
 | 
			
		||||
        'contributions/tesseract_ocr_pipeline_models/tesseract_ocr_pipeline_model.html.j2',
 | 
			
		||||
        'tesseract_ocr_pipeline_models/tesseract_ocr_pipeline_model.html.j2',
 | 
			
		||||
        title=f'{topm.title} {topm.version}',
 | 
			
		||||
        form=form,
 | 
			
		||||
        tesseract_ocr_pipeline_model=topm
 | 
			
		||||
							
								
								
									
										18
									
								
								app/blueprints/transkribus_htr_pipeline_models/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								app/blueprints/transkribus_htr_pipeline_models/__init__.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
from flask import Blueprint
 | 
			
		||||
from flask_login import login_required
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
bp = Blueprint('transkribus_htr_pipeline_models', __name__)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@bp.before_request
 | 
			
		||||
@login_required
 | 
			
		||||
def before_request():
 | 
			
		||||
    '''
 | 
			
		||||
    Ensures that the routes in this package can only be visited by users that
 | 
			
		||||
    are logged in.
 | 
			
		||||
    '''
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
from . import routes
 | 
			
		||||
@@ -3,5 +3,5 @@ from . import bp
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@bp.route('/transkribus_htr_pipeline_models')
 | 
			
		||||
def transkribus_htr_pipeline_models():
 | 
			
		||||
def index():
 | 
			
		||||
    return abort(503)
 | 
			
		||||
		Reference in New Issue
	
	Block a user