From 1b730c87983facfbfa2b3874c991c99dbf8d0d92 Mon Sep 17 00:00:00 2001 From: filak Date: Wed, 22 Jan 2025 22:35:19 +0100 Subject: [PATCH 01/15] Updates --- flask-app/application/main.py | 2 +- flask-app/application/modules/sparql.py | 3 ++- .../templates/sparql/search.sparql | 20 +++++-------------- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/flask-app/application/main.py b/flask-app/application/main.py index 25ac355..622c8c1 100644 --- a/flask-app/application/main.py +++ b/flask-app/application/main.py @@ -56,7 +56,7 @@ def create_app(debug=False, logger=None, port=5900, app.config.update(dict( APPLICATION_ROOT = url_prefix, APP_NAME = 'MTW', - APP_VER = '1.6.8', + APP_VER = '1.6.9', API_VER = '1.0.0', DBVERSION = 1.0, CACHE_DIR = mtu.get_instance_dir(app, 'cache'), diff --git a/flask-app/application/modules/sparql.py b/flask-app/application/modules/sparql.py index 92f6da3..551d20e 100644 --- a/flask-app/application/modules/sparql.py +++ b/flask-app/application/modules/sparql.py @@ -62,7 +62,8 @@ def getSparqlData(template, query='', show='', status='', top='', tn='', concept show=show, status=status, top=top, tn=tn, toptn=toptn, concept=concept, lang=lang, lang_umls=lang_umls, slang=slang, scr=scr) - # print(sparql) + if app.debug: + print(sparql) endpoint = app.config['SPARQL_HOST'] + app.config['SPARQL_DATASET'] + '/query' diff --git a/flask-app/application/templates/sparql/search.sparql b/flask-app/application/templates/sparql/search.sparql index 51c4d81..e6ee231 100644 --- a/flask-app/application/templates/sparql/search.sparql +++ b/flask-app/application/templates/sparql/search.sparql @@ -17,30 +17,22 @@ WHERE { (?s ?score) text:query ("{{ query }}" 500) . {% endif %} - OPTIONAL { - ?sub mesht:term|mesht:preferredTerm ?s . - ?d mesht:concept ?sub . - ?d rdf:type ?type . - ?d rdfs:label ?label . - FILTER(?type IN(meshv:TopicalDescriptor,meshv:GeographicalDescriptor,meshv:PublicationType,meshv:CheckTag,meshv:Qualifier)) - } - OPTIONAL { BIND(?s as ?d) ?s rdf:type ?type . ?s rdfs:label ?label . FILTER(?type IN(meshv:TopicalDescriptor,meshv:GeographicalDescriptor,meshv:PublicationType,meshv:CheckTag,meshv:Qualifier)) } - - {% if scr == 'yes' %} + + {% if scr == 'yes' %} OPTIONAL { ?s meshv:mappedTo|meshv:preferredMappedTo|meshv:pharmacologicalAction ?d . ?d rdf:type ?type . ?d rdfs:label ?label . FILTER (?type IN(meshv:TopicalDescriptor,meshv:Descriptor)) } - {% endif %} - + {% endif %} + OPTIONAL { ?d meshv:treeNumber ?s . ?d rdf:type ?type . @@ -71,7 +63,7 @@ WHERE { ?d mesht:concept ?s . ?d rdf:type ?type . } - + FILTER (BOUND(?d)) FILTER (?type IN(meshv:TopicalDescriptor,meshv:GeographicalDescriptor,meshv:PublicationType,meshv:CheckTag,meshv:Qualifier)) } @@ -157,5 +149,3 @@ ORDER BY DESC(?score) {% endif %} } LIMIT 500 - - From 622845adb4d196b42f04257afaafb85e871c6774 Mon Sep 17 00:00:00 2001 From: filak Date: Wed, 22 Jan 2025 22:51:50 +0100 Subject: [PATCH 02/15] Update sparql.py --- flask-app/application/modules/sparql.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flask-app/application/modules/sparql.py b/flask-app/application/modules/sparql.py index 551d20e..31bd2ab 100644 --- a/flask-app/application/modules/sparql.py +++ b/flask-app/application/modules/sparql.py @@ -63,7 +63,7 @@ def getSparqlData(template, query='', show='', status='', top='', tn='', concept lang=lang, lang_umls=lang_umls, slang=slang, scr=scr) if app.debug: - print(sparql) + print(sparql, '\n') endpoint = app.config['SPARQL_HOST'] + app.config['SPARQL_DATASET'] + '/query' From 589f904dd0d7fb71e3fbadf12aaa04c48a5f0665 Mon Sep 17 00:00:00 2001 From: filak Date: Thu, 23 Jan 2025 00:20:07 +0100 Subject: [PATCH 03/15] Update mesh.ttl --- flask-app/instance/conf/mesh.ttl | 64 +++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 10 deletions(-) diff --git a/flask-app/instance/conf/mesh.ttl b/flask-app/instance/conf/mesh.ttl index fd10a59..ec34dd2 100644 --- a/flask-app/instance/conf/mesh.ttl +++ b/flask-app/instance/conf/mesh.ttl @@ -8,7 +8,7 @@ @prefix meshv: . @prefix mesht: . -### Version 1.0.5 +### Version 1.1.0 ## Initialize text query [] ja:loadClass "org.apache.jena.query.text.TextQuery" . @@ -31,27 +31,71 @@ text:TextIndexES rdfs:subClassOf text:TextIndex . # A TDB dataset used for RDF storage <#dataset> a tdb2:DatasetTDB2 ; - tdb2:location "d:/Data/jena/databases/mesh" ; + tdb2:location "d:/apache-jena-data5/databases/mesh" ; . # Text index description <#indexLucene> a text:TextIndexLucene ; - text:directory "d:/Data/jena/indexes/mesh" ; + text:directory "d:/apache-jena-data5/indexes/mesh" ; text:entityMap <#entMap> ; - text:storeValues true ; - ##text:analyzer[ a text:StandardAnalyzer ] ; + text:storeValues false ; + ## text:analyzer[ a text:StandardAnalyzer ] ; text:analyzer [ a text:ConfigurableAnalyzer ; text:tokenizer text:StandardTokenizer ; - text:filters (text:ASCIIFoldingFilter text:LowerCaseFilter) + text:filters ( + text:ASCIIFoldingFilter + text:LowerCaseFilter + # text:PorterStemFilter + ) ] ; - ##text:queryAnalyzer [ a text:KeywordAnalyzer ] ; + ## text:queryAnalyzer [ a text:KeywordAnalyzer ] ; text:queryParser text:AnalyzingQueryParser ; - ##text:defineAnalyzers [ . . . ] ; + ## text:defineAnalyzers [ . . . ] ; text:multilingualSupport true ; - ## TBD https://jena.apache.org/documentation/query/text-query.html#lists-of-indexed-properties : - ## text:propLists ( [ . . . ] . . . ) ; + ## https://jena.apache.org/documentation/query/text-query.html#lists-of-indexed-properties - available since Jena 5.0 + text:propLists ( + [ text:propListProp mesht:defQuery ; + text:props ( + rdfs:label + meshv:identifier + meshv:prefLabel + meshv:altLabel + meshv:casn1_label + meshv:registryNumber + meshv:relatedRegistryNumber + mesht:identifier + mesht:prefLabel + mesht:altLabel + ) ; + ] + [ text:propListProp mesht:includeNotes ; + text:props ( + rdfs:label + meshv:identifier + meshv:prefLabel + meshv:altLabel + meshv:casn1_label + meshv:registryNumber + meshv:relatedRegistryNumber + mesht:identifier + mesht:prefLabel + mesht:altLabel + mesht:translatorsNote + mesht:annotation + mesht:historyNote + mesht:scopeNote + meshv:annotation + meshv:historyNote + meshv:note + meshv:onlineNote + meshv:publicMeSHNote + meshv:scopeNote + meshv:source + ) ; + ] + ) ; . <#entMap> From dd10a763169dfc6288ddb5416104eee199a03478 Mon Sep 17 00:00:00 2001 From: filak Date: Thu, 23 Jan 2025 00:23:15 +0100 Subject: [PATCH 04/15] Updates --- flask-app/application/modules/utils.py | 1 + .../application/templates/sparql/search.sparql | 15 ++++++++++++--- flask-app/mtw-server.py | 2 +- flask-app/mtw_requirements.txt | 4 +--- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/flask-app/application/modules/utils.py b/flask-app/application/modules/utils.py index 0eae61e..3eba79e 100644 --- a/flask-app/application/modules/utils.py +++ b/flask-app/application/modules/utils.py @@ -156,6 +156,7 @@ def getLocalConfValue(conf, fp=''): d['GCSP'] = json.loads(conf.get(section, 'GCSP')) d['CHAR_NORM_FILE'] = conf.get(section, 'CHAR_NORM_FILE', fallback='norm_chars_table.tsv.txt') d['MESH_BROWSER'] = conf.get(section, 'MESH_BROWSER', fallback='https://meshb.nlm.nih.gov/record/ui?ui=') + d['USE_PROP_LISTS'] = conf.getboolean(section, 'USE_PROP_LISTS', fallback=False) section = 'sparqlconf' d['SPARQL_HOST'] = conf.get(section, 'SPARQL_HOST', fallback='http://127.0.0.1:3030/') diff --git a/flask-app/application/templates/sparql/search.sparql b/flask-app/application/templates/sparql/search.sparql index e6ee231..6efcb8b 100644 --- a/flask-app/application/templates/sparql/search.sparql +++ b/flask-app/application/templates/sparql/search.sparql @@ -4,17 +4,26 @@ {% include 'sparql/_namespaces.sparql' %} +{% if config.USE_PROP_LISTS %} + {% set prop_list = 'mesht:defQuery' %} + {% if includeNotes == 'yes' %} + {% set prop_list = 'mesht:includeNotes' %} + {% endif %} +{% else %} + {% set prop_list = '' %} +{% endif %} + SELECT distinct ?label ?d ?type ?active ?val ?scn ?scnt ?ntx ?lockedBy { { SELECT distinct ?d ?type WHERE { {% if slang == 'target' %} - (?s ?score) text:query ("{{ query }}" 500 "lang:{{ lang }}") . + (?s ?score) text:query ({{ prop_list }} "{{ query }}" 500 "lang:{{ lang }}") . {% elif slang == 'source' %} - (?s ?score) text:query ("{{ query }}" 500 "lang:en") . + (?s ?score) text:query ({{ prop_list }} "{{ query }}" 500 "lang:en") . {% else %} - (?s ?score) text:query ("{{ query }}" 500) . + (?s ?score) text:query ({{ prop_list }} "{{ query }}" 500) . {% endif %} OPTIONAL { diff --git a/flask-app/mtw-server.py b/flask-app/mtw-server.py index 869a5f4..ef6926b 100644 --- a/flask-app/mtw-server.py +++ b/flask-app/mtw-server.py @@ -14,7 +14,7 @@ DEFAULT_PREFIX = 'mtw' appname = 'mtw-server' -appdesc = 'MTW Server 1.6.8' +appdesc = 'MTW Server 1.6.9' appusage = 'Help: ' + appname + ' -h \n' appauthor = 'Filip Kriz' diff --git a/flask-app/mtw_requirements.txt b/flask-app/mtw_requirements.txt index 64484b8..7524f11 100644 --- a/flask-app/mtw_requirements.txt +++ b/flask-app/mtw_requirements.txt @@ -1,4 +1,4 @@ -### Version 1.6.8 +### Version 1.6.9 ### Python 3.12 ### arrow==1.3.0 bcrypt==4.2.1 ## NOT python-bcrypt !!! @@ -24,11 +24,9 @@ pip_audit==2.7.3 ## Run: pip freeze > requirements.txt ; pip-audit ; pip-audit - pyuca==1.2 requests==2.32.3 requests_futures==1.0.2 -setuptools==75.6.0 urllib3==1.26.20 waitress==3.0.2 Werkzeug==3.1.3 -wheel==0.45.1 ### (optional) If building for Windows: pyinstaller==6.11.1; sys_platform == "win32" pyinstaller-hooks-contrib==2024.10; sys_platform == "win32" From 62c453b8f884036ad658f7cd302c9b34d3c7bb20 Mon Sep 17 00:00:00 2001 From: filak Date: Thu, 23 Jan 2025 01:11:02 +0100 Subject: [PATCH 05/15] Create drinks.ttl propLists testing --- flask-app/instance/conf/drinks.ttl | 85 ++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 flask-app/instance/conf/drinks.ttl diff --git a/flask-app/instance/conf/drinks.ttl b/flask-app/instance/conf/drinks.ttl new file mode 100644 index 0000000..5a7ee05 --- /dev/null +++ b/flask-app/instance/conf/drinks.ttl @@ -0,0 +1,85 @@ +@prefix : . +@prefix rdf: . +@prefix rdfs: . +@prefix tdb2: . +@prefix ja: . +@prefix text: . +@prefix fuseki: . +@prefix mt: . +@prefix mx: . + +## Initialize text query +[] ja:loadClass "org.apache.jena.query.text.TextQuery" . +# A TextDataset is a regular dataset with a text index. +text:TextDataset rdfs:subClassOf ja:RDFDataset . +# Lucene index +text:TextIndexLucene rdfs:subClassOf text:TextIndex . +# Elasticsearch index +text:TextIndexES rdfs:subClassOf text:TextIndex . + +## --------------------------------------------------------------- +## This URI must be fixed - it's used to assemble the text dataset. + +:text_dataset + a text:TextDataset ; + text:dataset <#dataset> ; + text:index <#indexLucene> ; + . + +# A TDB dataset used for RDF storage +<#dataset> + a tdb2:DatasetTDB2 ; + tdb2:location "d:/apache-jena-data5/databases/drinks" ; + . + +# Text index description +<#indexLucene> + a text:TextIndexLucene ; + text:directory "d:/apache-jena-data5/indexes/drinks" ; + text:entityMap <#entMap> ; + text:storeValues true ; + text:analyzer [ + a text:ConfigurableAnalyzer ; + text:tokenizer text:StandardTokenizer ; + text:filters (text:ASCIIFoldingFilter text:LowerCaseFilter) + ] ; + text:queryParser text:AnalyzingQueryParser ; + text:multilingualSupport true ; + text:propLists ( + [ text:propListProp mt:baseQuery ; + text:props ( + rdfs:label + ) ; + ] + [ text:propListProp mt:noteOnly ; + text:props ( + mt:note + ) ; + ] + ) ; + . + +<#entMap> + a text:EntityMap ; + text:defaultField "ftext" ; + text:entityField "uri" ; + text:uidField "uid" ; + text:langField "lang" ; + text:graphField "graph" ; + text:map ( + [ text:field "ftext" ; text:predicate rdfs:label ] + [ text:field "ftext" ; text:predicate mt:note ] + ) . + +<#service_text_tdb> + a fuseki:Service ; + rdfs:label "Drinks TEST" ; + fuseki:name "drinks" ; + fuseki:serviceQuery "query" ; + fuseki:serviceQuery "sparql" ; + fuseki:serviceUpdate "update" ; + fuseki:serviceUpload "upload" ; + fuseki:serviceReadGraphStore "get" ; + fuseki:serviceReadWriteGraphStore "data" ; + fuseki:dataset :text_dataset ; + . From 68c89c72969e88deeedf88a8632dad61c8304829 Mon Sep 17 00:00:00 2001 From: filak Date: Thu, 23 Jan 2025 01:22:16 +0100 Subject: [PATCH 06/15] Update mtw.ini --- flask-app/instance/conf/mtw.ini | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/flask-app/instance/conf/mtw.ini b/flask-app/instance/conf/mtw.ini index e8aa7c9..eee3af1 100644 --- a/flask-app/instance/conf/mtw.ini +++ b/flask-app/instance/conf/mtw.ini @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# *** Config version 1.6.5 *** +# *** Config version 1.6.9 *** ### Important values are marked with ! ### ### ! This file MUST BE UTF-8 encoded ! ### ### ! Restart the App after modifying ! ### @@ -79,8 +79,8 @@ CSRF_COOKIE_SECURE = False ### Flask-Caching params ## See: https://flask-caching.readthedocs.io/en/latest/ -#CACHING = {"CACHE_TYPE": "null"} -CACHING = {"CACHE_DEFAULT_TIMEOUT": 1800, "CACHE_THRESHOLD": 500} +CACHING = {"CACHE_TYPE": "null"} +#CACHING = {"CACHE_DEFAULT_TIMEOUT": 1800, "CACHE_THRESHOLD": 500} ### Flask-Session params ## See: https://flasksession.readthedocs.io/en/latest/ @@ -101,6 +101,8 @@ GCSP = {"script-src": "'self' ", CHAR_NORM_FILE = norm_chars_table.tsv.txt +### Uncomment only if using Jena +5.0 - use text:propLists defined in mesh.ttl - default: False +#USE_PROP_LISTS = True [worker] ### MTW Worker API settings - required ! @@ -113,7 +115,7 @@ API_TIMEOUT = 10 API_TOKEN_MAX_AGE = 10 #API_AUTH_BASIC_USER = test -#API_AUTH_BASIC_PWD = test +#API_AUTH_BASIC_PWD = test [sparqlconf] @@ -157,4 +159,3 @@ TRX_NOTES = annotation,considerAlso,historyNote DESC_NOTES = annotation,considerAlso,historyNote,onlineNote,publicMeSHNote,translatorsNote ROLES = manager,editor,contributor,viewer,disabled,locked - From f749bfa2fac4b8adc06917a9549bc36125673e44 Mon Sep 17 00:00:00 2001 From: filak Date: Thu, 23 Jan 2025 01:22:21 +0100 Subject: [PATCH 07/15] Update mtw-dist.ini --- flask-app/instance/conf/mtw-dist.ini | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/flask-app/instance/conf/mtw-dist.ini b/flask-app/instance/conf/mtw-dist.ini index 6ec6dfa..add1592 100644 --- a/flask-app/instance/conf/mtw-dist.ini +++ b/flask-app/instance/conf/mtw-dist.ini @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# *** Config version 1.6.5 *** +# *** Config version 1.6.9 *** ### Important values are marked with ! ### ### ! This file MUST BE UTF-8 encoded ! ### ### ! Restart the App after modifying ! ### @@ -99,6 +99,8 @@ GCSP = {"script-src": "'self' ", CHAR_NORM_FILE = norm_chars_table.tsv.txt +### Uncomment only if using Jena +5.0 - use text:propLists defined in mesh.ttl - default: False +#USE_PROP_LISTS = True [worker] ### MTW Worker API settings - required ! @@ -110,7 +112,7 @@ API_TIMEOUT = 10 API_TOKEN_MAX_AGE = 10 #API_AUTH_BASIC_USER = test -#API_AUTH_BASIC_PWD = test +#API_AUTH_BASIC_PWD = test [sparqlconf] @@ -154,4 +156,3 @@ TRX_NOTES = annotation,considerAlso,historyNote DESC_NOTES = annotation,considerAlso,historyNote,onlineNote,publicMeSHNote,translatorsNote ROLES = manager,editor,contributor,viewer,disabled,locked - From 7d3b25216509b8dc785fc82abe9010c329b1582b Mon Sep 17 00:00:00 2001 From: filak Date: Thu, 23 Jan 2025 10:26:50 +0100 Subject: [PATCH 08/15] Updates --- flask-app/!!build__dist_pyinstaller.bat | 10 ++ flask-app/application/modules/utils.py | 26 ++-- .../templates/modals/edit-concept.html | 13 +- .../application/templates/snips/concepts.html | 22 +-- .../application/templates/snips/terms.html | 6 +- .../templates/sparql/concepts_terms.sparql | 2 +- .../templates/sparql/search.sparql | 18 +-- flask-app/instance/conf/mesh.ttl | 66 ++++----- flask-app/mtw_requirements.txt | 4 +- flask-app/tools/secrets-gen.py | 14 ++ flask-app/tools/update-ns.py | 127 ++++++++++++++++++ 11 files changed, 235 insertions(+), 73 deletions(-) create mode 100644 flask-app/tools/secrets-gen.py create mode 100644 flask-app/tools/update-ns.py diff --git a/flask-app/!!build__dist_pyinstaller.bat b/flask-app/!!build__dist_pyinstaller.bat index 3933f0b..766a273 100644 --- a/flask-app/!!build__dist_pyinstaller.bat +++ b/flask-app/!!build__dist_pyinstaller.bat @@ -70,6 +70,16 @@ set extras= set subdir=tools\ call:buildFiles +set fileHandle=update-ns +set extras= +set subdir=tools\ +call:buildFiles + +set fileHandle=secrets-gen +set extras= +set subdir=tools\ +call:buildFiles + echo. echo Finished !!! echo. diff --git a/flask-app/application/modules/utils.py b/flask-app/application/modules/utils.py index 3eba79e..e533577 100644 --- a/flask-app/application/modules/utils.py +++ b/flask-app/application/modules/utils.py @@ -350,7 +350,7 @@ def getLookupJson(lookups, export): dui = item['dui'] d = {} - if item.get('active', '') == 'false': + if item.get('active') == 'false': d['active'] = False d['eng'] = item.get('den', '').replace('[OBSOLETE]', '').strip() else: @@ -379,7 +379,7 @@ def getLookupJson(lookups, export): if export == 'marc': if xterms.get(dui): - if xterms[dui].get('active') == 'true': + if xterms[dui].get('active', 'true') == 'true': # terms termsx nterms ntermsx for termtype in ['terms', 'termsx', 'nterms', 'ntermsx']: if xterms[dui].get(termtype): @@ -397,7 +397,7 @@ def getLookupJson(lookups, export): trees = item.get('trn', '').split('~') for trn in trees: if trn: - if item.get('active', '') == 'false': + if item.get('active') == 'false': trn = trn.replace('[OBSOLETE]', '').strip() if 'x' not in d['cat']: d['cat'].append('x') @@ -558,7 +558,7 @@ def getElasticData(data): # resp.append({'index': {'_id': trn, '_index': 'mesht'}}) resp.append({'id': dui, 'db': 'mesht', 'trn': trn.replace('.', '-'), 'eng': item.get('eng', ''), 'trx': item.get('trx', ''), - 'active': item.get('active')}) + 'active': item.get('active', 'true')}) # Add later by running: grind-data elastic mesh ... # resp.append({'index': {'_id': dui, '_index': 'mesh'}}) @@ -580,7 +580,7 @@ def getElasticData(data): # resp.append({'index': {'_id': trn, '_index': 'mesht'}}) resp.append({'id': dui, 'db': 'mesht', 'trn': trn.replace('.', '-'), 'eng': item.get('eng', ''), 'trx': item.get('trx', ''), - 'active': item.get('active')}) + 'active': item.get('active', 'true')}) if qualifs.get(dui): qa = [] @@ -761,7 +761,7 @@ def getLookupXml(lookups, export, as_string=True): trx = html.escape(items[k].get('trx', '')) dclass = items[k].get('dc', '-1') - if items[k].get('active') is False: + if items[k].get('active', True) is False: line = '<%s id="%s" eng="%s" trx="%s" dclass="%s" active="0" />\n' % (tag, k, eng, trx, dclass) else: line = '<%s id="%s" eng="%s" trx="%s" dclass="%s" />\n' % (tag, k, eng, trx, dclass) @@ -828,7 +828,7 @@ def getMarc(lookups, export, params, as_string=True): item = items[mid] - if item.get('active') is True: + if item.get('active', True): cnt += 1 marc.write(leader) marc.write(line_pref + '001' + code_pref + mid + '\n') @@ -880,7 +880,7 @@ def getMarc(lookups, export, params, as_string=True): marc.write('\n') qa = qualifs.get(mid) - if item.get('active') is True and qa and ecin == 'yes': + if item.get('active', True) and qa and ecin == 'yes': for qui in qa.split('~'): cnt += 1 marc.write(leader) @@ -949,7 +949,7 @@ def getMarcFields(dui, item, descriptors, qualifiers, qualifs, xnote, lp='=', cp btdx = [] for d in item.get('btd', []): des = descriptors.get(d) - if des.get('active') is True: + if des.get('active', True) is True: trx = des.get('trx') if not trx: trx = des.get('eng') @@ -965,7 +965,7 @@ def getMarcFields(dui, item, descriptors, qualifiers, qualifs, xnote, lp='=', cp ntdx = [] for d in item.get('ntd', []): des = descriptors.get(d) - if des.get('active') is True: + if des.get('active', True) is True: trx = des.get('trx') if not trx: trx = des.get('eng') @@ -981,7 +981,7 @@ def getMarcFields(dui, item, descriptors, qualifiers, qualifs, xnote, lp='=', cp rtdx = [] for d in item.get('rtd', []): des = descriptors.get(d) - if des.get('active') is True: + if des.get('active', True) is True: trx = des.get('trx') if not trx: trx = des.get('eng') @@ -997,7 +997,7 @@ def getMarcFields(dui, item, descriptors, qualifiers, qualifs, xnote, lp='=', cp pax = [] for d in item.get('pa', []): des = descriptors.get(d) - if des.get('active') is True: + if des.get('active', True) is True: trx = des.get('trx') if not trx: trx = des.get('eng') @@ -1410,7 +1410,7 @@ def getParamsForAudit(dui, concept, cui): par['cui'] = cui if citem: - par['active'] = citem['active'] + par['active'] = citem.get('active', True) par['label'] = citem['label'] par['rel'] = citem['rel'] par['terms'] = citem['terms']['target'] diff --git a/flask-app/application/templates/modals/edit-concept.html b/flask-app/application/templates/modals/edit-concept.html index dd9b951..c8d71f8 100644 --- a/flask-app/application/templates/modals/edit-concept.html +++ b/flask-app/application/templates/modals/edit-concept.html @@ -15,7 +15,7 @@