Commit 68806c4c authored by Pierre Dittgen's avatar Pierre Dittgen

Home page: fix schema name order

parent a21bf6f2
......@@ -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 %}
......
""" 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')
......@@ -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"]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment