from invenio_records.systemfields import ConstantField
from invenio_records_resources.records.systemfields import IndexField,

{% for import in current_model.pid_field_imports %}
    {% if import.alias %}
from {{ import.import|package_name }} import {{ import.import|base_name }} as {{ import.alias }}
    {% else %}
from {{ import.import|package_name }} import {{ import.import|base_name }}
    {% endif %}
{% endfor %}

{% for b in current_model.record_bases %}
from {{ b|package_name }} import {{ b|base_name }}
{% endfor %}
from {{ current_model.record_metadata_class|package_name }} import {{ current_model.record_metadata_class|base_name }}
from {{ current_model.record_dumper_class|package_name }} import {{ current_model.record_dumper_class|base_name }}

class {{ current_model.record_class|base_name }}({% for b in current_model.record_bases %}{{ b|base_name }}{{ ", " if not loop.last else "" }} {% endfor %}):
    model_cls = {{ current_model.record_metadata_class|base_name }}
{% if current_model.schema_name %}
    schema = ConstantField("$schema", "{{ current_model.schema_server }}{{ current_model.schema_name }}")
{% endif %}
{% if current_model.mapping_file %}
    index = IndexField("{{ current_model.index_name }}")
{% endif %}
{% if current_model.generate_record_pid_field %}
    pid = {{ current_model.pid_field_cls }}(
        provider={{ current_model.pid_field_provider }},
        context_cls={{ current_model.pid_field_context }}{% if current_model.pid_field_args %},
        {% for arg in current_model.pid_field_args %}{{ arg }}{{ ", " if not loop.last else "" }}{% endfor %}
    {% endif %}
    )
{% endif %}
    dumper_extensions = [
        {%- for ext in current_model.record_dumper_extensions %}{{ ext }}{% if not loop.last %}, {% endif %}{% endfor -%}
    ]
    dumper = {{ current_model.record_dumper_class|base_name }}(extensions=dumper_extensions)

{{ current_model.invenio_record_extra_code }}