Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Validata
Validata UI
Commits
83d52056
Commit
83d52056
authored
Dec 17, 2020
by
Pierre Dittgen
Browse files
fix badge
parent
d68b694a
Changes
4
Hide whitespace changes
Inline
Side-by-side
.env.example
View file @
83d52056
...
...
@@ -5,6 +5,9 @@ LOG_LEVEL="INFO"
# For production deployment, see http://flask.pocoo.org/docs/1.0/tutorial/deploy/#configure-the-secret-key
SECRET_KEY="dev"
# Badge config
BADGE_CONFIG_URL="https://git.opendatafrance.net/validata/validata-badge/raw/master/badge_conf.toml"
# Service used to produce SVG badge
# Comment the following line to disable badge display
SHIELDS_IO_BASE_URL="https://img.shields.io/"
...
...
CHANGELOG.md
View file @
83d52056
# Changelog
## next
-
Fix badge display
## 0.4.0a0
-
Migrate to new library
[
frictionless-py
](
https://github.com/frictionlessdata/frictionless-py
)
that replaces
`goodtables-py`
.
...
...
validata_ui/config.py
View file @
83d52056
...
...
@@ -29,6 +29,17 @@ logging.basicConfig(
SECRET_KEY
=
os
.
environ
.
get
(
"SECRET_KEY"
)
or
None
BADGE_CONFIG_URL
=
os
.
environ
.
get
(
"BADGE_CONFIG_URL"
)
or
None
BADGE_CONFIG
=
None
if
BADGE_CONFIG_URL
is
None
:
log
.
warning
(
"BADGE_CONFIG_URL environment variable is not set, disable badge feature"
)
else
:
response
=
requests
.
get
(
BADGE_CONFIG_URL
)
if
not
response
.
ok
:
log
.
warning
(
"Can't retrieve badge config from [%s], disable badge feature"
,
BADGE_CONFIG_URL
)
else
:
BADGE_CONFIG
=
toml
.
loads
(
response
.
text
)
SHIELDS_IO_BASE_URL
=
os
.
environ
.
get
(
"SHIELDS_IO_BASE_URL"
)
or
None
if
SHIELDS_IO_BASE_URL
:
SHIELDS_IO_BASE_URL
=
without_trailing_slash
(
SHIELDS_IO_BASE_URL
)
...
...
validata_ui/views.py
View file @
83d52056
...
...
@@ -559,7 +559,7 @@ def compute_badge_message_and_color(badge):
# No body error
if
body
==
"OK"
:
return
(
(
"
structure invalide"
,
"orange
"
)
(
"
partiellement valide"
,
"yellowgreen
"
)
if
structure
==
"WARN"
else
(
"valide"
,
"green"
)
)
...
...
@@ -593,13 +593,14 @@ def validate(schema_instance: SchemaInstance, validata_source: ValidataResource)
)
# disable badge
badge_
info
=
N
on
e
badge_
config
=
c
on
fig
.
BADGE_CONFIG
# Computes badge from report and badge configuration
badge_url
,
badge_msg
=
None
,
None
display_badge
=
badge_
info
and
config
.
SHIELDS_IO_BASE_URL
display_badge
=
badge_
config
and
config
.
SHIELDS_IO_BASE_URL
if
display_badge
:
badge_url
,
badge_msg
=
get_badge_url_and_message
(
badge_info
)
badge_stats
=
validata_core
.
compute_badge_metrics
(
validata_core_report
,
badge_config
)
badge_url
,
badge_msg
=
get_badge_url_and_message
(
badge_stats
)
# Source error
source_errors
=
[
...
...
@@ -680,7 +681,7 @@ def retrieve_schema_catalog(section):
exception_text
=
"
\n
"
.
join
([
str
(
arg
)
for
arg
in
exc
.
args
])
return
f
"""
{
err_msg
}
return
f
"""
{
err_msg
}
<div class="float-right">
<button type="button" class="btn btn-info btn-xs" data-toggle="collapse" data-target="#exception_info">détails</button>
</div>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment