Skip to content

Commit

Permalink
Fixing Digital.CSIC and adding FAQ to interface
Browse files Browse the repository at this point in the history
  • Loading branch information
ferag committed Apr 22, 2024
1 parent 243ccb0 commit 9980fc2
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 22 deletions.
24 changes: 12 additions & 12 deletions api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ def oai_check_record_url(oai_base, metadata_prefix, pid):

url = oai_base + action + params
logging.debug("Trying: " + url)
response = requests.get(url)
response = requests.get(url, verify=False)
error = 0
for tags in ET.fromstring(response.text).findall(
".//{http://www.openarchives.org/OAI/2.0/}error"
Expand All @@ -482,7 +482,7 @@ def oai_check_record_url(oai_base, metadata_prefix, pid):

url = oai_base + action + params
logging.debug("Trying: " + url)
response = requests.get(url)
response = requests.get(url, verify=False)
error = 0
for tags in ET.fromstring(response.text).findall(
".//{http://www.openarchives.org/OAI/2.0/}error"
Expand All @@ -499,7 +499,7 @@ def oai_check_record_url(oai_base, metadata_prefix, pid):

url = oai_base + action + params
logging.debug("Trying: " + url)
response = requests.get(url)
response = requests.get(url, verify=False)
error = 0
for tags in ET.fromstring(response.text).findall(
".//{http://www.openarchives.org/OAI/2.0/}error"
Expand All @@ -516,7 +516,7 @@ def oai_check_record_url(oai_base, metadata_prefix, pid):

url = oai_base + action + params
logging.debug("Trying: " + url)
response = requests.get(url)
response = requests.get(url, verify=False)
error = 0
for tags in ET.fromstring(response.text).findall(
".//{http://www.openarchives.org/OAI/2.0/}error"
Expand Down Expand Up @@ -693,7 +693,7 @@ def orcid_basic_info(orcid):
}
try:
url = "https://pub.orcid.org/v3.0/" + orcid
r = requests.get(url, headers=headers) # GET with headers
r = requests.get(url, verify=False, headers=headers) # GET with headers
xmlTree = ET.fromstring(r.text)
item = xmlTree.findall(
".//{http://www.orcid.org/ns/common}assertion-origin-name"
Expand All @@ -708,7 +708,7 @@ def orcid_basic_info(orcid):
def loc_basic_info(loc):
# Returns the first line of json LD
headers = {"Accept": "application/json"} # Type of response accpeted
r = requests.get(loc, headers=headers) # GET with headers
r = requests.get(loc, verify=False, headers=headers) # GET with headers
output = r.json()
return output[0]

Expand All @@ -720,7 +720,7 @@ def geonames_basic_info(geonames):
geonames = geonames[0 : geonames.index("/")]
url = "http://api.geonames.org/get?geonameId=%s&username=frames" % geonames
headers = {"Accept": "application/json"} # Type of response accpeted
r = requests.get(url, headers=headers) # GET with headers
r = requests.get(url, verify=False, headers=headers) # GET with headers
logging.debug("Request genoames: %s" % r.text)
output = ""
try:
Expand All @@ -736,7 +736,7 @@ def coar_check(coar):
coar = coar[0 : coar.index("/")]
coar = coar.replace("resource_type", "resource_types")
url = "https://vocabularies.coar-repositories.org/%s" % coar
r = requests.get(url) # GET with headers
r = requests.get(url, verify=False) # GET with headers
logging.debug("Request coar: %s" % r.text)
if r.status_code == 200:
return True, "purl.org/coar"
Expand All @@ -746,7 +746,7 @@ def coar_check(coar):

def wikidata_check(wikidata):
logging.debug("Checking wikidata")
r = requests.head(wikidata) # GET with headers
r = requests.head(wikidata, verify=False) # GET with headers
logging.debug("Request coar: %s" % r.text)
if r.status_code == 200:
return True, "wikidata.org/wiki"
Expand Down Expand Up @@ -788,7 +788,7 @@ def get_rdf_metadata_format(oai_base):
def licenses_list():
url = "https://spdx.org/licenses/licenses.json"
headers = {"Accept": "application/json"} # Type of response accpeted
r = requests.get(url, headers=headers) # GET with headers
r = requests.get(url, verify=False, headers=headers) # GET with headers
output = r.json()
licenses = []
for e in output["licenses"]:
Expand All @@ -799,7 +799,7 @@ def licenses_list():
def is_spdx_license(license_id, machine_readable=False):
url = "https://spdx.org/licenses/licenses.json"
headers = {"Accept": "application/json"} # Type of response accpeted
r = requests.get(url, headers=headers) # GET with headers
r = requests.get(url, verify=False, headers=headers) # GET with headers
payload = r.json()
is_spdx = False
license_list = []
Expand Down Expand Up @@ -837,7 +837,7 @@ def resolve_handle(handle_id):
resolves = False
endpoint = urljoin("https://hdl.handle.net/api/", "handles/%s" % handle_id)
headers = {"Content-Type": "application/json"}
r = requests.get(endpoint, headers=headers)
r = requests.get(endpoint, verify=False, headers=headers)
if not r.ok:
msg = "Error while making a request to endpoint: %s (status code: %s)" % (
endpoint,
Expand Down
20 changes: 12 additions & 8 deletions plugins/digital_csic/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ def __init__(self, item_id, oai_base=None, lang="en"):
if self.id_type == "doi" or self.id_type == "handle":
api_endpoint = "https://digital.csic.es"
api_metadata = None
# api_metadata, self.file_list = self.get_metadata_api(
# api_endpoint, self.item_id, self.id_type
# )
api_metadata, self.file_list = self.get_metadata_api(
api_endpoint, self.item_id, self.id_type
)
if api_metadata is not None:
if len(api_metadata) > 0:
logger.debug("A102: MEtadata from API OK")
Expand Down Expand Up @@ -314,13 +314,10 @@ def get_metadata_api(self, api_endpoint, item_pid, item_type):
return metadata, file_list

def get_metadata_db(self):
query = (
"SELECT metadatavalue.text_value, metadataschemaregistry.short_id, metadatafieldregistry.element,\
query = 'SELECT metadatavalue.text_value, metadataschemaregistry.short_id, metadatafieldregistry.element,\
metadatafieldregistry.qualifier FROM item, metadatavalue, metadataschemaregistry, metadatafieldregistry WHERE item.item_id = %s and \
item.item_id = metadatavalue.resource_id AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id \
AND metadatafieldregistry.metadata_schema_id = metadataschemaregistry.metadata_schema_id"
% self.internal_id
)
AND metadatafieldregistry.metadata_schema_id = metadataschemaregistry.metadata_schema_id AND resource_type_id = 2' % self.internal_id
cursor = self.connection.cursor()
cursor.execute(query)
metadata = pd.DataFrame(
Expand Down Expand Up @@ -899,12 +896,19 @@ def rda_i1_02m(self):
msg
Message with the results or recommendations to improve this indicator
"""
identifier_temp = self.item_id
df = pd.DataFrame(self.metadata)

# Hacer la selección donde la columna 'term' es igual a 'identifier' y 'qualifier' es igual a 'uri'
selected_handle = df.loc[(df['element'] == 'identifier') & (df['qualifier'] == 'uri'), 'text_value']
self.item_id = ut.get_handle_str(selected_handle.iloc[0])
points, msg_list = super().rda_i1_02m()
try:
points = (points * self.metadata_quality) / 100
msg_list.append({"message": _("After applying weigh"), "points": points})
except Exception as e:
logging.error(e)
self.item_id = identifier_temp
return (points, msg_list)

@ConfigTerms(term_id="terms_qualified_references")
Expand Down
2 changes: 1 addition & 1 deletion templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@


<li><a href="/about_us">{{ _('About us') }}</a></li>

<li><a href="/faq">{{ _('FAQs') }}</a></li>

<li><a href="/evaluations">{{ _('Evaluations') }}</a></li>

Expand Down
41 changes: 41 additions & 0 deletions templates/faq.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{% extends 'base.html' %}
{% block body %}
{% block content %}



<!-- DATOS TOTALES -->


<div class="works" id="metodologia">
<div class="container">
<!-- default heading -->
<div class="default-heading3">
<!-- heading -->
<h2>Frequent Asked Questions</h2>
<div>
<h3>¿Qué es FAIR EVA?</h3>
<p>FAIR EVA</p>
</div>

<div>
<h3>¿Cómo se obtienen los datos y metadatos?</h3>
<p>Para DIGITAL.CSIC: Base de datos, API o OAI-PMH</p>
</div>

<div>
<h3>¿Cómo se puntúa?</h3>
<p>Pesos</p>
</div>

<div>
<h3>¿Pueden cambiar las puntuaciones</h3>
<p>Sí, en caso de problema...</p>
</div>




{% include "snippets/footer.html" %}
{% endblock %}
{% endblock %}
6 changes: 5 additions & 1 deletion web.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def set_parser():
"TITLE": config["local"]["title"],
"DEBUG": True,
"FLASK_DEBUG": 1,
"PATHS": ["about_us", "evaluator", "export_pdf", "evaluations"],
"PATHS": ["about_us", "evaluator", "export_pdf", "evaluations", "faq"],
"BABEL_DEFAULT_LOCALE": "es",
"BABEL_LOCALES": [
"en",
Expand Down Expand Up @@ -183,6 +183,10 @@ def index():
def not_found():
return render_template("not-found.html")

@app.route("/es/faq", endpoint="faq_es")
@app.route("/en/faq", endpoint="faq_en")
def faq():
return render_template("faq.html")

@app.route("/es/about_us", endpoint="about_us_es")
@app.route("/en/about_us", endpoint="about_us_en")
Expand Down

0 comments on commit 9980fc2

Please sign in to comment.