mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-04 04:12:45 +00:00 
			
		
		
		
	Move some blueprints and rename routes
This commit is contained in:
		@@ -16,3 +16,10 @@ def before_request():
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
from . import routes
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
from .spacy_nlp_pipeline_models import bp as spacy_nlp_pipeline_models_bp
 | 
			
		||||
bp.register_blueprint(spacy_nlp_pipeline_models_bp, url_prefix='/spacy-nlp-pipeline-models')
 | 
			
		||||
 | 
			
		||||
from .tesseract_ocr_pipeline_models import bp as tesseract_ocr_pipeline_models_bp
 | 
			
		||||
bp.register_blueprint(tesseract_ocr_pipeline_models_bp, url_prefix='/tesseract-ocr-pipeline-models')
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
from flask import redirect, url_for
 | 
			
		||||
from flask import render_template
 | 
			
		||||
from . import bp
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@bp.route('')
 | 
			
		||||
def index():
 | 
			
		||||
    return redirect(url_for('main.dashboard', _anchor='contributions'))
 | 
			
		||||
    return render_template('contributions/index.html.j2', title='Contributions')
 | 
			
		||||
 
 | 
			
		||||
@@ -12,10 +12,7 @@ from .forms import (
 | 
			
		||||
@bp.route('/')
 | 
			
		||||
@login_required
 | 
			
		||||
def index():
 | 
			
		||||
    return render_template(
 | 
			
		||||
        'spacy_nlp_pipeline_models/index.html.j2',
 | 
			
		||||
        title='SpaCy NLP Pipeline Models'
 | 
			
		||||
    )
 | 
			
		||||
    return redirect(url_for('contributions.index', _anchor='spacy-nlp-pipeline-models'))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@bp.route('/create', methods=['GET', 'POST'])
 | 
			
		||||
@@ -46,7 +43,7 @@ def create():
 | 
			
		||||
        flash(f'SpaCy NLP Pipeline model "{snpm.title}" created')
 | 
			
		||||
        return {}, 201, {'Location': url_for('.index')}
 | 
			
		||||
    return render_template(
 | 
			
		||||
        'spacy_nlp_pipeline_models/create.html.j2',
 | 
			
		||||
        'contributions/spacy_nlp_pipeline_models/create.html.j2',
 | 
			
		||||
        title='Create SpaCy NLP Pipeline Model',
 | 
			
		||||
        form=form
 | 
			
		||||
    )
 | 
			
		||||
@@ -54,7 +51,7 @@ def create():
 | 
			
		||||
 | 
			
		||||
@bp.route('/<hashid:spacy_nlp_pipeline_model_id>', methods=['GET', 'POST'])
 | 
			
		||||
@login_required
 | 
			
		||||
def spacy_nlp_pipeline_model(spacy_nlp_pipeline_model_id):
 | 
			
		||||
def entity(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):
 | 
			
		||||
        abort(403)
 | 
			
		||||
@@ -66,7 +63,7 @@ def spacy_nlp_pipeline_model(spacy_nlp_pipeline_model_id):
 | 
			
		||||
            db.session.commit()
 | 
			
		||||
        return redirect(url_for('.index'))
 | 
			
		||||
    return render_template(
 | 
			
		||||
        'spacy_nlp_pipeline_models/spacy_nlp_pipeline_model.html.j2',
 | 
			
		||||
        'contributions/spacy_nlp_pipeline_models/entity.html.j2',
 | 
			
		||||
        title=f'{snpm.title} {snpm.version}',
 | 
			
		||||
        form=form,
 | 
			
		||||
        spacy_nlp_pipeline_model=snpm
 | 
			
		||||
@@ -11,10 +11,7 @@ from .forms import (
 | 
			
		||||
 | 
			
		||||
@bp.route('/')
 | 
			
		||||
def index():
 | 
			
		||||
    return render_template(
 | 
			
		||||
        'tesseract_ocr_pipeline_models/index.html.j2',
 | 
			
		||||
        title='Tesseract OCR Pipeline Models'
 | 
			
		||||
    )
 | 
			
		||||
    return redirect(url_for('contributions.index', _anchor='tesseract-ocr-pipeline-models'))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@bp.route('/create', methods=['GET', 'POST'])
 | 
			
		||||
@@ -43,14 +40,14 @@ def create():
 | 
			
		||||
        flash(f'Tesseract OCR Pipeline model "{topm.title}" created')
 | 
			
		||||
        return {}, 201, {'Location': url_for('.index')}
 | 
			
		||||
    return render_template(
 | 
			
		||||
        'tesseract_ocr_pipeline_models/create.html.j2',
 | 
			
		||||
        'contributions/tesseract_ocr_pipeline_models/create.html.j2',
 | 
			
		||||
        title='Create Tesseract OCR Pipeline Model',
 | 
			
		||||
        form=form
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@bp.route('/<hashid:tesseract_ocr_pipeline_model_id>', methods=['GET', 'POST'])
 | 
			
		||||
def tesseract_ocr_pipeline_model(tesseract_ocr_pipeline_model_id):
 | 
			
		||||
def entity(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):
 | 
			
		||||
        abort(403)
 | 
			
		||||
@@ -62,7 +59,7 @@ def tesseract_ocr_pipeline_model(tesseract_ocr_pipeline_model_id):
 | 
			
		||||
            db.session.commit()
 | 
			
		||||
        return redirect(url_for('.index'))
 | 
			
		||||
    return render_template(
 | 
			
		||||
        'tesseract_ocr_pipeline_models/tesseract_ocr_pipeline_model.html.j2',
 | 
			
		||||
        'contributions/tesseract_ocr_pipeline_models/entity.html.j2',
 | 
			
		||||
        title=f'{topm.title} {topm.version}',
 | 
			
		||||
        form=form,
 | 
			
		||||
        tesseract_ocr_pipeline_model=topm
 | 
			
		||||
@@ -72,14 +72,14 @@ def terms_of_use():
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@bp.route('/social-area')
 | 
			
		||||
@bp.route('/social')
 | 
			
		||||
@login_required
 | 
			
		||||
def social_area():
 | 
			
		||||
def social():
 | 
			
		||||
    corpora = Corpus.query.filter(Corpus.is_public == True, Corpus.user != current_user).all()
 | 
			
		||||
    users = User.query.filter(User.is_public == True, User.id != current_user.id).all()
 | 
			
		||||
    return render_template(
 | 
			
		||||
        'main/social_area.html.j2',
 | 
			
		||||
        title='Social Area',
 | 
			
		||||
        'main/social.html.j2',
 | 
			
		||||
        title='Social',
 | 
			
		||||
        corpora=corpora,
 | 
			
		||||
        users=users
 | 
			
		||||
    )
 | 
			
		||||
 
 | 
			
		||||
@@ -1,18 +0,0 @@
 | 
			
		||||
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
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
from flask import abort
 | 
			
		||||
from . import bp
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@bp.route('/transkribus_htr_pipeline_models')
 | 
			
		||||
def index():
 | 
			
		||||
    return abort(503)
 | 
			
		||||
		Reference in New Issue
	
	Block a user