diff --git a/app/__init__.py b/app/__init__.py index 75df4689..9953a1cf 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -104,15 +104,6 @@ def create_app(config: Config = Config) -> Flask: from .blueprints.contributions import bp as contributions_blueprint app.register_blueprint(contributions_blueprint, url_prefix='/contributions') - from .blueprints.spacy_nlp_pipeline_models import bp as spacy_nlp_pipeline_models_blueprint - app.register_blueprint(spacy_nlp_pipeline_models_blueprint, url_prefix='/contributions/spacy-nlp-pipeline-models') - - from .blueprints.tesseract_ocr_pipeline_models import bp as tesseract_ocr_pipeline_models_blueprint - app.register_blueprint(tesseract_ocr_pipeline_models_blueprint, url_prefix='/contributions/tesseract-ocr-pipeline-models') - - from.blueprints.transkribus_htr_pipeline_models import bp as transkribus_htr_pipeline_models_blueprint - app.register_blueprint(transkribus_htr_pipeline_models_blueprint, url_prefix='/contributions/transkribus-htr-pipeline-models') - from .blueprints.corpora import bp as corpora_blueprint app.register_blueprint(corpora_blueprint, cli_group='corpus', url_prefix='/corpora') diff --git a/app/blueprints/contributions/__init__.py b/app/blueprints/contributions/__init__.py index 4b9ca33c..02513a7f 100644 --- a/app/blueprints/contributions/__init__.py +++ b/app/blueprints/contributions/__init__.py @@ -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') diff --git a/app/blueprints/contributions/routes.py b/app/blueprints/contributions/routes.py index 0cfd2014..2141b572 100644 --- a/app/blueprints/contributions/routes.py +++ b/app/blueprints/contributions/routes.py @@ -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') diff --git a/app/blueprints/spacy_nlp_pipeline_models/__init__.py b/app/blueprints/contributions/spacy_nlp_pipeline_models/__init__.py similarity index 100% rename from app/blueprints/spacy_nlp_pipeline_models/__init__.py rename to app/blueprints/contributions/spacy_nlp_pipeline_models/__init__.py diff --git a/app/blueprints/spacy_nlp_pipeline_models/forms.py b/app/blueprints/contributions/spacy_nlp_pipeline_models/forms.py similarity index 100% rename from app/blueprints/spacy_nlp_pipeline_models/forms.py rename to app/blueprints/contributions/spacy_nlp_pipeline_models/forms.py diff --git a/app/blueprints/spacy_nlp_pipeline_models/json_routes.py b/app/blueprints/contributions/spacy_nlp_pipeline_models/json_routes.py similarity index 100% rename from app/blueprints/spacy_nlp_pipeline_models/json_routes.py rename to app/blueprints/contributions/spacy_nlp_pipeline_models/json_routes.py diff --git a/app/blueprints/spacy_nlp_pipeline_models/routes.py b/app/blueprints/contributions/spacy_nlp_pipeline_models/routes.py similarity index 88% rename from app/blueprints/spacy_nlp_pipeline_models/routes.py rename to app/blueprints/contributions/spacy_nlp_pipeline_models/routes.py index 2463c24e..a353a124 100644 --- a/app/blueprints/spacy_nlp_pipeline_models/routes.py +++ b/app/blueprints/contributions/spacy_nlp_pipeline_models/routes.py @@ -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('/', 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 diff --git a/app/blueprints/tesseract_ocr_pipeline_models/__init__.py b/app/blueprints/contributions/tesseract_ocr_pipeline_models/__init__.py similarity index 100% rename from app/blueprints/tesseract_ocr_pipeline_models/__init__.py rename to app/blueprints/contributions/tesseract_ocr_pipeline_models/__init__.py diff --git a/app/blueprints/tesseract_ocr_pipeline_models/forms.py b/app/blueprints/contributions/tesseract_ocr_pipeline_models/forms.py similarity index 100% rename from app/blueprints/tesseract_ocr_pipeline_models/forms.py rename to app/blueprints/contributions/tesseract_ocr_pipeline_models/forms.py diff --git a/app/blueprints/tesseract_ocr_pipeline_models/json_routes.py b/app/blueprints/contributions/tesseract_ocr_pipeline_models/json_routes.py similarity index 100% rename from app/blueprints/tesseract_ocr_pipeline_models/json_routes.py rename to app/blueprints/contributions/tesseract_ocr_pipeline_models/json_routes.py diff --git a/app/blueprints/tesseract_ocr_pipeline_models/routes.py b/app/blueprints/contributions/tesseract_ocr_pipeline_models/routes.py similarity index 86% rename from app/blueprints/tesseract_ocr_pipeline_models/routes.py rename to app/blueprints/contributions/tesseract_ocr_pipeline_models/routes.py index d07766d6..7674686b 100644 --- a/app/blueprints/tesseract_ocr_pipeline_models/routes.py +++ b/app/blueprints/contributions/tesseract_ocr_pipeline_models/routes.py @@ -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('/', 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 diff --git a/app/blueprints/main/routes.py b/app/blueprints/main/routes.py index d865b9a5..e34e6f58 100644 --- a/app/blueprints/main/routes.py +++ b/app/blueprints/main/routes.py @@ -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 ) diff --git a/app/blueprints/transkribus_htr_pipeline_models/__init__.py b/app/blueprints/transkribus_htr_pipeline_models/__init__.py deleted file mode 100644 index 07b16e36..00000000 --- a/app/blueprints/transkribus_htr_pipeline_models/__init__.py +++ /dev/null @@ -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 diff --git a/app/blueprints/transkribus_htr_pipeline_models/routes.py b/app/blueprints/transkribus_htr_pipeline_models/routes.py deleted file mode 100644 index c0fe3bb1..00000000 --- a/app/blueprints/transkribus_htr_pipeline_models/routes.py +++ /dev/null @@ -1,7 +0,0 @@ -from flask import abort -from . import bp - - -@bp.route('/transkribus_htr_pipeline_models') -def index(): - return abort(503) diff --git a/app/models/spacy_nlp_pipeline_model.py b/app/models/spacy_nlp_pipeline_model.py index ee23e06d..4aa10ce9 100644 --- a/app/models/spacy_nlp_pipeline_model.py +++ b/app/models/spacy_nlp_pipeline_model.py @@ -41,7 +41,7 @@ class SpaCyNLPPipelineModel(FileMixin, HashidMixin, db.Model): @property def url(self): return url_for( - 'contributions.spacy_nlp_pipeline_model', + 'contributions.spacy_nlp_pipeline_models.entity', spacy_nlp_pipeline_model_id=self.id ) diff --git a/app/models/tesseract_ocr_pipeline_model.py b/app/models/tesseract_ocr_pipeline_model.py index b23e7efb..e1512ca7 100644 --- a/app/models/tesseract_ocr_pipeline_model.py +++ b/app/models/tesseract_ocr_pipeline_model.py @@ -40,7 +40,7 @@ class TesseractOCRPipelineModel(FileMixin, HashidMixin, db.Model): @property def url(self): return url_for( - 'contributions.tesseract_ocr_pipeline_model', + 'contributions.tesseract_ocr_pipeline_models.entity', tesseract_ocr_pipeline_model_id=self.id ) diff --git a/app/templates/_base/navbar_primary_content.html.j2 b/app/templates/_base/navbar_primary_content.html.j2 index 83ffbf51..c4f40ed1 100644 --- a/app/templates/_base/navbar_primary_content.html.j2 +++ b/app/templates/_base/navbar_primary_content.html.j2 @@ -38,7 +38,7 @@ {# social #}
  • - + groups Social diff --git a/app/templates/_base/sidenav.html.j2 b/app/templates/_base/sidenav.html.j2 index 625292de..b8be43f5 100644 --- a/app/templates/_base/sidenav.html.j2 +++ b/app/templates/_base/sidenav.html.j2 @@ -16,8 +16,14 @@
  • dashboardDashboard
  • -
  • - groupsSocial +
  • + + new_label + Contributions + +
  • +
  • + groupsSocial
  • help_outlineManual diff --git a/app/templates/tesseract_ocr_pipeline_models/index.html.j2 b/app/templates/contributions/index.html.j2 similarity index 50% rename from app/templates/tesseract_ocr_pipeline_models/index.html.j2 rename to app/templates/contributions/index.html.j2 index 98abc0aa..dbc7e564 100644 --- a/app/templates/tesseract_ocr_pipeline_models/index.html.j2 +++ b/app/templates/contributions/index.html.j2 @@ -1,5 +1,4 @@ {% extends "base.html.j2" %} -{% import "wtf.html.j2" as wtf %} {% block page_content %}
    @@ -9,17 +8,27 @@

    Here you can see and edit the models that you have created. You can also create new models.

    +
    +
    +
    +
    +
    +
    + addCreate +
    +
    +
    + - {% endblock page_content %} diff --git a/app/templates/spacy_nlp_pipeline_models/create.html.j2 b/app/templates/contributions/spacy_nlp_pipeline_models/create.html.j2 similarity index 100% rename from app/templates/spacy_nlp_pipeline_models/create.html.j2 rename to app/templates/contributions/spacy_nlp_pipeline_models/create.html.j2 diff --git a/app/templates/spacy_nlp_pipeline_models/spacy_nlp_pipeline_model.html.j2 b/app/templates/contributions/spacy_nlp_pipeline_models/entity.html.j2 similarity index 100% rename from app/templates/spacy_nlp_pipeline_models/spacy_nlp_pipeline_model.html.j2 rename to app/templates/contributions/spacy_nlp_pipeline_models/entity.html.j2 diff --git a/app/templates/tesseract_ocr_pipeline_models/create.html.j2 b/app/templates/contributions/tesseract_ocr_pipeline_models/create.html.j2 similarity index 100% rename from app/templates/tesseract_ocr_pipeline_models/create.html.j2 rename to app/templates/contributions/tesseract_ocr_pipeline_models/create.html.j2 diff --git a/app/templates/tesseract_ocr_pipeline_models/tesseract_ocr_pipeline_model.html.j2 b/app/templates/contributions/tesseract_ocr_pipeline_models/entity.html.j2 similarity index 100% rename from app/templates/tesseract_ocr_pipeline_models/tesseract_ocr_pipeline_model.html.j2 rename to app/templates/contributions/tesseract_ocr_pipeline_models/entity.html.j2 diff --git a/app/templates/main/dashboard.html.j2 b/app/templates/main/dashboard.html.j2 index bd3a8240..0f054a52 100644 --- a/app/templates/main/dashboard.html.j2 +++ b/app/templates/main/dashboard.html.j2 @@ -41,97 +41,10 @@
    - -
    -

    My Contributions

    -
    - -
    -
    - -
    - Tesseract OCR Pipeline Models -

    Here you can see and edit the models that you have created. You can also create new models.

    -
    -
    -
    - -
    -
    - -
    - SpaCy NLP Pipeline Models -

    Here you can see and edit the models that you have created. You can also create new models.

    -
    -
    -
    - - {% if config.NOPAQUE_TRANSKRIBUS_ENABLED %} -
    -
    - -
    - Transkribus HTR Pipeline Models -

    Here you can see and edit the models that you have created. You can also create new models.

    -
    -
    -
    - {% endif %} {% endblock page_content %} - -{% block modals %} -{{ super() }} - -{% endblock modals %} diff --git a/app/templates/main/social_area.html.j2 b/app/templates/main/social.html.j2 similarity index 100% rename from app/templates/main/social_area.html.j2 rename to app/templates/main/social.html.j2 diff --git a/app/templates/spacy_nlp_pipeline_models/index.html.j2 b/app/templates/spacy_nlp_pipeline_models/index.html.j2 deleted file mode 100644 index 852161b9..00000000 --- a/app/templates/spacy_nlp_pipeline_models/index.html.j2 +++ /dev/null @@ -1,24 +0,0 @@ -{% extends "base.html.j2" %} -{% import "wtf.html.j2" as wtf %} - -{% block page_content %} -
    -
    -
    -

    {{ title }}

    -

    Here you can see and edit the models that you have created. You can also create new models.

    -
    - -
    -
    -
    -
    -
    -
    - addCreate -
    -
    -
    -
    -
    -{% endblock page_content %}