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
68806c4c
Commit
68806c4c
authored
Jul 01, 2019
by
Pierre Dittgen
Browse files
Home page: fix schema name order
parent
a21bf6f2
Changes
3
Hide whitespace changes
Inline
Side-by-side
validata_ui/templates/home.html
View file @
68806c4c
...
...
@@ -16,7 +16,7 @@
<div
class=
"form-group col-lg-9"
>
<select
required
name=
"schema_name"
class=
"form-control"
>
<option
disabled
selected
value=
""
>
Choisissez un schéma
</option>
{% for item in section.catalog
| sort(attribute='title')
%}
{% for item in section.catalog %}
<option
value=
"{{ section.name }}.{{ item.name }}"
>
{{ item.title }}
</option>
{% endfor %}
</select>
...
...
@@ -34,7 +34,7 @@
<p
class=
"text-muted"
>
{{ section.description }}
</p>
{% endif %}
<div
class=
"alert alert-danger"
role=
"alert"
>
Catalogue indisponible
: {{ section.err }}
Catalogue indisponible: {{ section.err }}
</div>
</div>
{% endif %}
...
...
validata_ui/validata_util.py
View file @
68806c4c
""" Call validation code """
import
logging
import
unicodedata
from
abc
import
ABC
,
abstractmethod
from
io
import
BytesIO
from
pathlib
import
Path
...
...
@@ -60,3 +61,9 @@ class UploadedFileValidataResource(ValidataResource):
'format'
:
self
.
__detect_format_from_file_extension
()
}
return
(
self
.
build_reader
(),
options
)
def
strip_accents
(
s
):
"""Remove accents from string, used to sort normalized strings"""
return
''
.
join
(
c
for
c
in
unicodedata
.
normalize
(
'NFD'
,
s
)
if
unicodedata
.
category
(
c
)
!=
'Mn'
)
validata_ui/views.py
View file @
68806c4c
...
...
@@ -25,7 +25,7 @@ from opendataschema import GitSchemaReference, by_commit_date
from
.
import
app
,
config
,
schema_catalog_registry
,
tableschema_from_url
from
.ui_util
import
flash_error
,
flash_warning
from
.validata_util
import
UploadedFileValidataResource
,
URLValidataResource
,
ValidataResource
from
.validata_util
import
UploadedFileValidataResource
,
URLValidataResource
,
ValidataResource
,
strip_accents
MonkeyPatch
.
patch_fromisoformat
()
...
...
@@ -463,7 +463,8 @@ def home():
"name"
:
schema_reference
.
name
,
"title"
:
table_schema
.
descriptor
.
get
(
"title"
)
or
schema_reference
.
name
,
})
home_section
[
'catalog'
]
=
home_section_catalog
home_section
[
'catalog'
]
=
sorted
(
home_section_catalog
,
key
=
lambda
sc
:
strip_accents
(
sc
[
'title'
].
lower
()))
if
"links"
in
section
:
home_section
[
"links"
]
=
section
[
"links"
]
...
...
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