Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
V
validata-ui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
19
Issues
19
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Validata
validata-ui
Commits
659dddec
Commit
659dddec
authored
Jun 25, 2019
by
Christophe Benz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rationalise URL building
parent
406fe564
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
15 deletions
+14
-15
validata_ui/__init__.py
validata_ui/__init__.py
+0
-7
validata_ui/templates/validation_report.html
validata_ui/templates/validation_report.html
+1
-1
validata_ui/views.py
validata_ui/views.py
+13
-7
No files found.
validata_ui/__init__.py
View file @
659dddec
...
...
@@ -3,7 +3,6 @@ import logging
import
os
import
re
from
pathlib
import
Path
from
urllib.parse
import
quote_plus
import
cachecontrol
import
flask
...
...
@@ -89,12 +88,6 @@ if config.MATOMO_AUTH_TOKEN and config.MATOMO_BASE_URL and config.MATOMO_SITE_ID
blueprint
=
flask
.
Blueprint
(
'filters'
,
__name__
)
@
jinja2
.
contextfilter
@
blueprint
.
app_template_filter
()
def
urlencode
(
context
,
value
):
return
quote_plus
(
value
)
@
jinja2
.
contextfilter
@
blueprint
.
app_template_filter
()
def
commonmark2html
(
context
,
value
):
...
...
validata_ui/templates/validation_report.html
View file @
659dddec
...
...
@@ -32,7 +32,7 @@
{% if source.type == 'url' %}
<p
class=
"hidden-print"
>
<a
class=
"btn btn-outline-secondary"
href=
"{{ pdf_report_url }}
&url={{source.url|urlencode}}
"
target=
"_blank"
>
<a
class=
"btn btn-outline-secondary"
href=
"{{ pdf_report_url }}"
target=
"_blank"
>
Télécharger en PDF
</a>
</p>
...
...
validata_ui/views.py
View file @
659dddec
...
...
@@ -11,7 +11,7 @@ import tempfile
from
datetime
import
datetime
from
operator
import
itemgetter
from
pathlib
import
Path
from
urllib.parse
import
quote_plus
,
urlencode
from
urllib.parse
import
urlencode
,
urljoin
import
requests
import
tableschema
...
...
@@ -321,8 +321,11 @@ def get_badge_url_and_message(badge):
"""Gets badge url from badge information"""
msg
,
color
=
compute_badge_message_and_color
(
badge
)
return
(
'{}static/v1.svg?label=Validata&message={}&color={}'
.
format
(
config
.
SHIELDS_IO_BASE_URL
,
quote_plus
(
msg
),
color
),
msg
)
badge_url
=
"{}?{}"
.
format
(
urljoin
(
config
.
SHIELDS_IO_BASE_URL
,
'/static/v1.svg'
),
urlencode
({
"label"
:
"Validata"
,
"message"
:
msg
,
"color"
:
color
}),
)
return
(
badge_url
,
msg
)
def
validate
(
schema_instance
:
SchemaInstance
,
source
:
ValidataResource
):
...
...
@@ -384,7 +387,11 @@ def validate(schema_instance: SchemaInstance, source: ValidataResource):
# Display report to the user
validator_form_url
=
compute_validation_form_url
(
schema_instance
.
request_parameters
())
schema_info
=
compute_schema_info
(
schema_instance
.
schema
,
schema_instance
.
url
)
pdf_report_url
=
url_for
(
'pdf_report'
)
+
'?'
+
urlencode
(
schema_instance
.
request_parameters
())
pdf_report_url
=
"{}?{}"
.
format
(
url_for
(
'pdf_report'
),
urlencode
({
**
schema_instance
.
request_parameters
(),
"url"
:
source
.
url
,
}))
return
render_template
(
'validation_report.html'
,
badge_msg
=
badge_msg
,
...
...
@@ -471,7 +478,7 @@ def pdf_report():
'url'
:
url_param
,
**
schema_instance
.
request_parameters
()
}
validation_url
=
base_url
+
'?'
+
urlencode
(
parameter_dict
)
validation_url
=
"{}?{}"
.
format
(
base_url
,
urlencode
(
parameter_dict
)
)
# Create temp file to save validation report
with
tempfile
.
NamedTemporaryFile
(
prefix
=
'validata_{}_report_'
.
format
(
datetime
.
now
().
timestamp
()),
suffix
=
'.pdf'
)
as
tmpfile
:
...
...
@@ -521,8 +528,7 @@ def compute_schema_info(table_schema: tableschema.Schema, schema_url):
def
compute_validation_form_url
(
request_parameters
:
dict
):
"""Computes validation form url with schema URL parameter"""
url
=
url_for
(
'custom_validator'
)
param_list
=
[
'{}={}'
.
format
(
k
,
quote_plus
(
v
))
for
k
,
v
in
request_parameters
.
items
()]
return
"{}?{}"
.
format
(
url
,
'&'
.
join
(
param_list
))
return
"{}?{}"
.
format
(
url
,
urlencode
(
request_parameters
))
@
app
.
route
(
'/table-schema'
,
methods
=
[
'GET'
,
'POST'
])
...
...
Write
Preview
Markdown
is supported
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