Ejemplo n.º 1
0
    def h_translate_facet(cls, label, facet):
        if facet == 'groups':
            group = model.Group.get(label)
            title_i18n = fluent_text_output(group.extras['title_i18n'])

            return title_i18n[h.lang()]

        elif facet == 'vocab_reuse_conditions':
            return cls.h_vocab_reuse_conditions_captions()[label]

        elif facet == 'has_any_reuse_conditions':
            if asbool(label):
                return _('Restrictions set')
            else:
                return _('No restrictions')

        return label
Ejemplo n.º 2
0
    def validator(key, data, errors, context):
        """
        Copy keywords to tags.
        This will let the tag autocomplete endpoint to work as desired.

        Fluent tag validation and CKAN's tag validation handles validation.

        This replaces tags with the keywords for all languages in the schema
        so it will remove (deactivate) tags as necessary as well.

        This validator is dependent on scheming and fluent.

        Usage:
        "validators": "fluent_tags ontario_theme_copy_fluent_keywords_to_tags",
        """

        fluent_tags = fluent_text_output(data[key])
        data[('tags'), ] = []
        for key, value in fluent_tags.items():
            for tag in value:
                data[('tags'), ].append({'name': tag})
Ejemplo n.º 3
0
def fluent_text_output_backcompat(value):
    try:
        return fluent_text_output(value)
    except Exception:
        return {h.lang(): value}
Ejemplo n.º 4
0
def fluent_text_output_backcompat(value):
    try:
        return fluent_text_output(value)
    except Exception:
        return {h.lang(): value}