From 42ad6e27e2294da918680bd2fdd84e31194e4bcb Mon Sep 17 00:00:00 2001
From: Patrick Jentsch
Date: Mon, 11 Jul 2022 12:14:01 +0200
Subject: [PATCH] Add Contributions Mockup and fix email notifications on job
status change
---
app/__init__.py | 4 ++--
app/{contribute => contributions}/__init__.py | 2 +-
app/contributions/forms.py | 15 +++++++++++++++
app/{contribute => contributions}/routes.py | 8 +++++++-
app/models.py | 2 ++
app/templates/_sidenav.html.j2 | 2 +-
6 files changed, 28 insertions(+), 5 deletions(-)
rename app/{contribute => contributions}/__init__.py (54%)
create mode 100644 app/contributions/forms.py
rename app/{contribute => contributions}/routes.py (75%)
diff --git a/app/__init__.py b/app/__init__.py
index 27233b15..de64a195 100644
--- a/app/__init__.py
+++ b/app/__init__.py
@@ -57,8 +57,8 @@ def create_app(config: Config = Config) -> Flask:
from .auth import bp as auth_blueprint
app.register_blueprint(auth_blueprint, url_prefix='/auth')
- from .contribute import bp as contribute_blueprint
- app.register_blueprint(contribute_blueprint, url_prefix='/contribute')
+ from .contributions import bp as contributions_blueprint
+ app.register_blueprint(contributions_blueprint, url_prefix='/contributions')
from .corpora import bp as corpora_blueprint
app.register_blueprint(corpora_blueprint, url_prefix='/corpora')
diff --git a/app/contribute/__init__.py b/app/contributions/__init__.py
similarity index 54%
rename from app/contribute/__init__.py
rename to app/contributions/__init__.py
index 15d172ec..af9747a6 100644
--- a/app/contribute/__init__.py
+++ b/app/contributions/__init__.py
@@ -1,5 +1,5 @@
from flask import Blueprint
-bp = Blueprint('contribute', __name__)
+bp = Blueprint('contributions', __name__)
from . import routes
diff --git a/app/contributions/forms.py b/app/contributions/forms.py
new file mode 100644
index 00000000..205f1740
--- /dev/null
+++ b/app/contributions/forms.py
@@ -0,0 +1,15 @@
+from app.models import User
+from flask_wtf import FlaskForm
+from wtforms import (
+ BooleanField,
+ PasswordField,
+ StringField,
+ SubmitField,
+ ValidationError
+)
+from wtforms.validators import DataRequired, InputRequired, Email, EqualTo, Length, Regexp
+from . import USERNAME_REGEX
+
+
+class ContributeTesseractOCRModel(FlaskForm):
+ pass
diff --git a/app/contribute/routes.py b/app/contributions/routes.py
similarity index 75%
rename from app/contribute/routes.py
rename to app/contributions/routes.py
index 8bfd9bd8..94462a83 100644
--- a/app/contribute/routes.py
+++ b/app/contributions/routes.py
@@ -1,3 +1,4 @@
+from ast import Pass
from app import db
from app.decorators import permission_required
from app.models import Permission, Role, User
@@ -14,6 +15,11 @@ def before_request():
pass
-@bp.route('/')
+@bp.route('')
def index():
pass
+
+
+@bp.route('/tesseract_ocr_model', methods=['GET', 'POST'])
+def tesseract_ocr_model():
+ pass
diff --git a/app/models.py b/app/models.py
index ce3686c8..68eb8ab0 100644
--- a/app/models.py
+++ b/app/models.py
@@ -1088,6 +1088,8 @@ def job_after_update_handler(mapper, connection, job):
for attr in db.inspect(job).attrs:
if attr.key != 'status':
continue
+ if not attr.load_history().has_changes():
+ return
if job.user.setting_job_status_mail_notification_level == UserSettingJobStatusMailNotificationLevel.NONE:
return
if job.user.setting_job_status_mail_notification_level == UserSettingJobStatusMailNotificationLevel.END:
diff --git a/app/templates/_sidenav.html.j2 b/app/templates/_sidenav.html.j2
index 08d8f163..92592a7f 100644
--- a/app/templates/_sidenav.html.j2
+++ b/app/templates/_sidenav.html.j2
@@ -32,7 +32,7 @@
admin_panel_settingsAdministration
{% endif %}
{% if current_user.can(Permission.CONTRIBUTE) %}
- new_labelContribute
+ new_labelContribute
{% endif %}
{% if current_user.can(Permission.USE_API) %}
apiAPI