diff --git a/app/SpaCyNLPPipelineModel.defaults.yml b/app/SpaCyNLPPipelineModel.defaults.yml index 055c6181..a51d9149 100644 --- a/app/SpaCyNLPPipelineModel.defaults.yml +++ b/app/SpaCyNLPPipelineModel.defaults.yml @@ -30,7 +30,7 @@ pipeline_name: 'el_core_news_md' version: '3.2.0' compatible_service_versions: - - '0.1.0' + - '0.1.0' - title: 'English' description: 'English pipeline optimized for CPU. Components: tok2vec, tagger, parser, senter, ner, attribute_ruler, lemmatizer.' url: 'https://github.com/explosion/spacy-models/releases/download/en_core_web_md-3.2.0/en_core_web_md-3.2.0.tar.gz' @@ -42,7 +42,6 @@ version: '3.2.0' compatible_service_versions: - '0.1.0' - - 'test' - title: 'Spanish' description: 'Spanish pipeline optimized for CPU. Components: tok2vec, morphologizer, parser, senter, ner, attribute_ruler, lemmatizer.' url: 'https://github.com/explosion/spacy-models/releases/download/es_core_news_md-3.2.0/es_core_news_md-3.2.0.tar.gz' diff --git a/app/models.py b/app/models.py index f4889bbd..cbe25379 100644 --- a/app/models.py +++ b/app/models.py @@ -1,6 +1,5 @@ from datetime import datetime, timedelta from enum import Enum, IntEnum -import re from flask import current_app, url_for from flask_hashids import HashidMixin from flask_login import UserMixin @@ -550,6 +549,10 @@ class TesseractOCRPipelineModel(FileMixin, HashidMixin, db.Model): str(self.id) ) + @property + def jsonpatch_path(self): + return f'{self.user.jsonpatch_path}/tesseract_ocr_pipeline_models/{self.hashid}' + @property def url(self): return url_for( @@ -557,6 +560,10 @@ class TesseractOCRPipelineModel(FileMixin, HashidMixin, db.Model): tesseract_ocr_pipeline_model_id=self.id ) + @property + def user_hashid(self): + return self.user.hashid + @staticmethod def insert_defaults(): nopaque_user = User.query.filter_by(username='nopaque').first() @@ -665,6 +672,10 @@ class SpaCyNLPPipelineModel(FileMixin, HashidMixin, db.Model): str(self.id) ) + @property + def jsonpatch_path(self): + return f'{self.user.jsonpatch_path}/spacy_nlp_pipeline_models/{self.hashid}' + @property def url(self): return url_for( @@ -672,6 +683,10 @@ class SpaCyNLPPipelineModel(FileMixin, HashidMixin, db.Model): spacy_nlp_pipeline_model_id=self.id ) + @property + def user_hashid(self): + return self.user.hashid + @staticmethod def insert_defaults(): nopaque_user = User.query.filter_by(username='nopaque').first() diff --git a/app/static/js/RessourceLists/SpacyNLPPipelineModelList.js b/app/static/js/RessourceLists/SpacyNLPPipelineModelList.js index 66bce648..057e7c4c 100644 --- a/app/static/js/RessourceLists/SpacyNLPPipelineModelList.js +++ b/app/static/js/RessourceLists/SpacyNLPPipelineModelList.js @@ -123,12 +123,7 @@ class SpaCyNLPPipelineModelList extends RessourceList { let spaCyNLPPipelineModelId = spaCyNLPPipelineModelElement.dataset.id; switch (action) { case 'share-request': { - let shared; - if (actionSwitchElement.querySelector('input').checked) { - shared = true; - } else { - shared = false; - } + let shared = actionSwitchElement.querySelector('input').checked; Utils.shareSpaCyNLPPipelineModelRequest(this.userId, spaCyNLPPipelineModelId, shared); break; } diff --git a/app/static/js/RessourceLists/TesseractOCRPipelineModelList.js b/app/static/js/RessourceLists/TesseractOCRPipelineModelList.js index b527ec18..33e7f432 100644 --- a/app/static/js/RessourceLists/TesseractOCRPipelineModelList.js +++ b/app/static/js/RessourceLists/TesseractOCRPipelineModelList.js @@ -123,12 +123,7 @@ class TesseractOCRPipelineModelList extends RessourceList { let tesseractOCRPipelineModelId = tesseractOCRPipelineModelElement.dataset.id; switch (action) { case 'share-request': { - let shared; - if (actionSwitchElement.querySelector('input').checked) { - shared = true; - } else { - shared = false; - } + let shared = actionSwitchElement.querySelector('input').checked; Utils.shareTesseractOCRPipelineModelRequest(this.userId, tesseractOCRPipelineModelId, shared); break; }