
{{ vars.search_options|imports }}
from oarepo_runtime.i18n import lazy_gettext as _
from . import facets

{% for extra_field_value in vars.search_options.fields.values() %}
{{ extra_field_value|code_imports }}
{% endfor %}


class {{ vars.search_options| class_header }}:
    """{{ vars.record.class|base_name }} search options."""

    facet_groups = {
        {% for group in facet_groups %}
            '{{ group }}': {
                {% for dict in facet_groups[group].keys() %}
                    '{{ dict}}' : {{ facet_groups[group][dict] }},

                {%  endfor %}
            {% for base_class in vars.search_options.base_classes %}
                **getattr({{ base_class|base_name }}, 'facet_groups', {}).get('{{group }}', {})
            {% endfor %}
            },
        {%  endfor %}
    }

    facets = {
{% for dict in default_group %}
{% for key, value in dict.items()%}
    '{{ key }}': {{ value }},
{% endfor %}
{% endfor %}
{% for base_class in vars.search_options.base_classes %}
    **getattr({{ base_class|base_name }}, 'facets', {})
{% endfor %}
    }

{% if sort_definition %}
    {{ vars.search_options.sort_options_field }} = {
        {% if vars.search_options.base_classes %}
            {% for base_class in vars.search_options.base_classes %}
                **{{ base_class|base_name }}.{{ vars.search_options.sort_options_field }},
            {% endfor %}
{#        **{{ vars.search_options_bases[0]|base_name }}.sort_options,#}
        {% else %}
        **InvenioSearchOptions.{{ vars.search_options.sort_options_field }},
        {% endif %}
{% for dict in sort_definition %}
{% for key, value in dict.items()%}
    '{{ key }}': {{ value }},
{% endfor %}
{% endfor %}
    }
{% endif %}
{% for extra_field_name, extra_field_value in vars.search_options.fields.items() %}
    {{ extra_field_name }} = {{ extra_field_value|extra_code }}
{% endfor %}

{{ vars.search_options|extra_code }}
