diff --git a/app/corpora/routes.py b/app/corpora/routes.py index 36e19e2b..bbe98090 100644 --- a/app/corpora/routes.py +++ b/app/corpora/routes.py @@ -48,6 +48,16 @@ def corpus(corpus_id): corpus = Corpus.query.get_or_404(corpus_id) if not (corpus.user == current_user or current_user.is_administrator()): 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( 'corpora/corpus.html.j2', corpus=corpus, diff --git a/app/models.py b/app/models.py index 8efc4bd2..6719ca72 100644 --- a/app/models.py +++ b/app/models.py @@ -612,7 +612,6 @@ class TranskribusHTRModel(HashidMixin, db.Model): # Fields shared = db.Column(db.Boolean, default=False) transkribus_model_id = db.Column(db.Integer) - transkribus_name = db.Column(db.String(64)) # Backrefs: user: User @staticmethod @@ -630,8 +629,8 @@ class TranskribusHTRModel(HashidMixin, db.Model): model.transkribus_model_id = m['modelId'] continue model = TranskribusHTRModel( - shared=True, transkribus_model_id=m['modelId'], + shared=True, user=nopaque_user, ) db.session.add(model) @@ -1065,6 +1064,7 @@ class Corpus(HashidMixin, db.Model): title = db.Column(db.String(32)) num_analysis_sessions = 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 # Relationships files = db.relationship( @@ -1170,7 +1170,8 @@ class Corpus(HashidMixin, db.Model): None if self.last_edited_date is None else f'{self.last_edited_date.isoformat()}Z' ), - 'title': self.title + 'title': self.title, + 'is_public': self.is_public } if backrefs: _json['user'] = self.user.to_json(backrefs=True) diff --git a/app/services/forms.py b/app/services/forms.py index 106c0f7f..008e0d0a 100644 --- a/app/services/forms.py +++ b/app/services/forms.py @@ -10,7 +10,11 @@ from wtforms import ( ValidationError ) from wtforms.validators import InputRequired, Length -from app.models import TesseractOCRModel, TranskribusHTRModel +from app.models import ( + TRANSKRIBUS_HTR_MODELS, + TesseractOCRModel, + TranskribusHTRModel +) from . import SERVICES @@ -119,7 +123,7 @@ class CreateTranskribusHTRPipelineJobForm(CreateJobBaseForm): if x.shared == True or x.user == current_user ] 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.version.choices = [(x, x) for x in service_manifest['versions']] self.version.data = version diff --git a/migrations/versions/260b57d5f4e7_.py b/migrations/versions/260b57d5f4e7_.py new file mode 100644 index 00000000..8f5fd95b --- /dev/null +++ b/migrations/versions/260b57d5f4e7_.py @@ -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 ###