mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
Fix TranskribusHTRModel display problems
This commit is contained in:
parent
1c8f4f7e9c
commit
ca27f2e6f2
@ -48,6 +48,16 @@ def corpus(corpus_id):
|
|||||||
corpus = Corpus.query.get_or_404(corpus_id)
|
corpus = Corpus.query.get_or_404(corpus_id)
|
||||||
if not (corpus.user == current_user or current_user.is_administrator()):
|
if not (corpus.user == current_user or current_user.is_administrator()):
|
||||||
abort(403)
|
abort(403)
|
||||||
|
# cool = False
|
||||||
|
# if corpus.is_public:
|
||||||
|
# cool = True
|
||||||
|
# elif current_user.is_authenticated:
|
||||||
|
# if corpus.user == current_user or current_user.is_administrator:
|
||||||
|
# cool = True
|
||||||
|
# else:
|
||||||
|
# abort(403)
|
||||||
|
# else:
|
||||||
|
# return current_app.login_manager.unauthorized()
|
||||||
return render_template(
|
return render_template(
|
||||||
'corpora/corpus.html.j2',
|
'corpora/corpus.html.j2',
|
||||||
corpus=corpus,
|
corpus=corpus,
|
||||||
|
@ -612,7 +612,6 @@ class TranskribusHTRModel(HashidMixin, db.Model):
|
|||||||
# Fields
|
# Fields
|
||||||
shared = db.Column(db.Boolean, default=False)
|
shared = db.Column(db.Boolean, default=False)
|
||||||
transkribus_model_id = db.Column(db.Integer)
|
transkribus_model_id = db.Column(db.Integer)
|
||||||
transkribus_name = db.Column(db.String(64))
|
|
||||||
# Backrefs: user: User
|
# Backrefs: user: User
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -630,8 +629,8 @@ class TranskribusHTRModel(HashidMixin, db.Model):
|
|||||||
model.transkribus_model_id = m['modelId']
|
model.transkribus_model_id = m['modelId']
|
||||||
continue
|
continue
|
||||||
model = TranskribusHTRModel(
|
model = TranskribusHTRModel(
|
||||||
shared=True,
|
|
||||||
transkribus_model_id=m['modelId'],
|
transkribus_model_id=m['modelId'],
|
||||||
|
shared=True,
|
||||||
user=nopaque_user,
|
user=nopaque_user,
|
||||||
)
|
)
|
||||||
db.session.add(model)
|
db.session.add(model)
|
||||||
@ -1065,6 +1064,7 @@ class Corpus(HashidMixin, db.Model):
|
|||||||
title = db.Column(db.String(32))
|
title = db.Column(db.String(32))
|
||||||
num_analysis_sessions = db.Column(db.Integer, default=0)
|
num_analysis_sessions = db.Column(db.Integer, default=0)
|
||||||
num_tokens = db.Column(db.Integer, default=0)
|
num_tokens = db.Column(db.Integer, default=0)
|
||||||
|
is_public = db.Column(db.Boolean, default=False)
|
||||||
# Backrefs: user: User
|
# Backrefs: user: User
|
||||||
# Relationships
|
# Relationships
|
||||||
files = db.relationship(
|
files = db.relationship(
|
||||||
@ -1170,7 +1170,8 @@ class Corpus(HashidMixin, db.Model):
|
|||||||
None if self.last_edited_date is None
|
None if self.last_edited_date is None
|
||||||
else f'{self.last_edited_date.isoformat()}Z'
|
else f'{self.last_edited_date.isoformat()}Z'
|
||||||
),
|
),
|
||||||
'title': self.title
|
'title': self.title,
|
||||||
|
'is_public': self.is_public
|
||||||
}
|
}
|
||||||
if backrefs:
|
if backrefs:
|
||||||
_json['user'] = self.user.to_json(backrefs=True)
|
_json['user'] = self.user.to_json(backrefs=True)
|
||||||
|
@ -10,7 +10,11 @@ from wtforms import (
|
|||||||
ValidationError
|
ValidationError
|
||||||
)
|
)
|
||||||
from wtforms.validators import InputRequired, Length
|
from wtforms.validators import InputRequired, Length
|
||||||
from app.models import TesseractOCRModel, TranskribusHTRModel
|
from app.models import (
|
||||||
|
TRANSKRIBUS_HTR_MODELS,
|
||||||
|
TesseractOCRModel,
|
||||||
|
TranskribusHTRModel
|
||||||
|
)
|
||||||
from . import SERVICES
|
from . import SERVICES
|
||||||
|
|
||||||
|
|
||||||
@ -119,7 +123,7 @@ class CreateTranskribusHTRPipelineJobForm(CreateJobBaseForm):
|
|||||||
if x.shared == True or x.user == current_user
|
if x.shared == True or x.user == current_user
|
||||||
]
|
]
|
||||||
self.model.choices = [('', 'Choose your option')]
|
self.model.choices = [('', 'Choose your option')]
|
||||||
self.model.choices += [(x.hashid, x.transkribus_name) for x in models]
|
self.model.choices += [(x.hashid, [y['name'] for y in TRANSKRIBUS_HTR_MODELS if y['modelId'] == x.transkribus_model_id ][0]) for x in models]
|
||||||
self.model.default = ''
|
self.model.default = ''
|
||||||
self.version.choices = [(x, x) for x in service_manifest['versions']]
|
self.version.choices = [(x, x) for x in service_manifest['versions']]
|
||||||
self.version.data = version
|
self.version.data = version
|
||||||
|
28
migrations/versions/260b57d5f4e7_.py
Normal file
28
migrations/versions/260b57d5f4e7_.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
"""Remove transkribus_name column from transkribus_htr_models table
|
||||||
|
|
||||||
|
Revision ID: 260b57d5f4e7
|
||||||
|
Revises: 2c4e27331ccb
|
||||||
|
Create Date: 2022-10-04 13:26:47.186931
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '260b57d5f4e7'
|
||||||
|
down_revision = '2c4e27331ccb'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_column('transkribus_htr_models', 'transkribus_name')
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.add_column('transkribus_htr_models', sa.Column('transkribus_name', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
|
||||||
|
# ### end Alembic commands ###
|
Loading…
Reference in New Issue
Block a user