diff --git a/app/corpora/routes.py b/app/corpora/routes.py index 47fadaf6..1535f834 100644 --- a/app/corpora/routes.py +++ b/app/corpora/routes.py @@ -71,7 +71,8 @@ def corpus(corpus_id): users = users ) if (current_user.is_following_corpus(corpus) or corpus.is_public): - cfas = CorpusFollowerAssociation.query.filter(Corpus.id == corpus_id, CorpusFollowerAssociation.follower_id != current_user.id, CorpusFollowerAssociation. follower_id != corpus.user.id).all() + cfas = CorpusFollowerAssociation.query.filter(Corpus.id == corpus_id, CorpusFollowerAssociation.follower_id != corpus.user.id).all() + print(cfas) return render_template( 'corpora/public_corpus.html.j2', title=corpus.title, diff --git a/app/services/forms.py b/app/services/forms.py index 01b1cdd8..174bdb71 100644 --- a/app/services/forms.py +++ b/app/services/forms.py @@ -168,12 +168,18 @@ class CreateSpacyNLPPipelineJobForm(CreateJobBaseForm): if 'methods' in service_info: if 'encoding_detection' in service_info['methods']: del self.encoding_detection.render_kw['disabled'] - models = [ - x for x in SpaCyNLPPipelineModel.query.order_by(SpaCyNLPPipelineModel.title).all() - if version in x.compatible_service_versions and (x.is_public == True or x.user == current_user) + user_models = [ + x for x in current_user.spacy_nlp_pipeline_models.order_by(SpaCyNLPPipelineModel.title).all() ] - self.model.choices = [('', 'Choose your option')] - self.model.choices += [(x.hashid, f'{x.title} [{x.version}]') for x in models] + models = [ + x for x in SpaCyNLPPipelineModel.query.filter(SpaCyNLPPipelineModel.user != current_user, SpaCyNLPPipelineModel.is_public == True).order_by(SpaCyNLPPipelineModel.title).all() + if version in x.compatible_service_versions + ] + self.model.choices = { + '': [('', 'Choose your option')], + 'Your models': [(x.hashid, f'{x.title} [{x.version}]') for x in user_models], + 'Public models': [(x.hashid, f'{x.title} [{x.version}]') 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/app/static/js/ResourceLists/CorpusFollowerList.js b/app/static/js/ResourceLists/CorpusFollowerList.js index 975e69c1..9db964c1 100644 --- a/app/static/js/ResourceLists/CorpusFollowerList.js +++ b/app/static/js/ResourceLists/CorpusFollowerList.js @@ -23,8 +23,9 @@ class CorpusFollowerList extends ResourceList { }); app.getUser(this.userId).then((user) => { let corpusFollowerAssociations = Object.values(user.corpora[this.corpusId].corpus_follower_associations); - let filteredList = corpusFollowerAssociations.filter(association => association.follower.id != currentUserId); - this.add(filteredList); + // let filteredList = corpusFollowerAssociations.filter(association => association.follower.id != currentUserId); + // this.add(filteredList); + this.add(Object.values(user.corpora[this.corpusId].corpus_follower_associations)); this.isInitialized = true; }); } @@ -42,7 +43,7 @@ class CorpusFollowerList extends ResourceList {
- diff --git a/app/static/js/ResourceLists/PublicCorpusList.js b/app/static/js/ResourceLists/PublicCorpusList.js index c02d54f0..4b5f5ecb 100644 --- a/app/static/js/ResourceLists/PublicCorpusList.js +++ b/app/static/js/ResourceLists/PublicCorpusList.js @@ -2,14 +2,37 @@ class PublicCorpusList extends CorpusList { get item() { return ` - book
- send `.trim(); } + + initListContainerElement() { + if (!this.listContainerElement.hasAttribute('id')) { + this.listContainerElement.id = Utils.generateElementId('corpus-list-'); + } + let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`); + this.listContainerElement.innerHTML = ` +
+ search + + +
+ + + + + + + + + +
Title and DescriptionOwner
+ + `.trim(); + } } diff --git a/app/templates/_scripts.html.j2 b/app/templates/_scripts.html.j2 index bee5b7b2..f3b18003 100644 --- a/app/templates/_scripts.html.j2 +++ b/app/templates/_scripts.html.j2 @@ -85,7 +85,13 @@ for (let optionElement of document.querySelectorAll('option[value=""]')) { optionElement.disabled = true; } - + for (let optgroupElement of document.querySelectorAll('optgroup[label=""]')) { + for (let c of optgroupElement.children) { + optgroupElement.parentElement.insertAdjacentElement('afterbegin', c); + } + optgroupElement.remove(); + + } // Set the data-length attribute on textareas/inputs with the maxlength attribute for (let inputElement of document.querySelectorAll('textarea[maxlength], input[maxlength]')) { inputElement.dataset.length = inputElement.getAttribute('maxlength'); diff --git a/app/templates/corpora/public_corpus.html.j2 b/app/templates/corpora/public_corpus.html.j2 index 6ace0f7a..e8512189 100644 --- a/app/templates/corpora/public_corpus.html.j2 +++ b/app/templates/corpora/public_corpus.html.j2 @@ -8,6 +8,9 @@

{{ corpus.title }}

+ {% for cfa in cfas %} + {{ cfa.follower.username|tojson }}, + {% endfor %}
diff --git a/app/templates/users/user.html.j2 b/app/templates/users/user.html.j2 index bdd6ed75..238edd7e 100644 --- a/app/templates/users/user.html.j2 +++ b/app/templates/users/user.html.j2 @@ -126,7 +126,7 @@ let followedCorpusList = new PublicCorpusList(document.querySelector('.followed- followedCorpusList.add( [ {% for corpus in user.followed_corpora %} - {% if (corpus.is_public or corpus.user == current_user) %} + {% if (corpus.is_public or corpus.user == current_user or user == current_user or current_user.is_following_corpus(corpus)) %} {{ corpus.to_json_serializeable(backrefs=True)|tojson }}, {% endif %} {% endfor %}