1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <!--
- This file is part of Lodel 2 (https://github.com/OpenEdition)
-
- Copyright (C) 2015-2017 Cléo UMS-3287
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- -->
-
-
- {% macro display(obj) -%}
- <!-- To get a component HTML code, it is necessary to call : components.<macro_name>(args) -->
- {% for fieldn, fieldv in obj.fields(include_ro = True).items() %}
- {% if fieldv is not none %}
- {% if fieldv.base_type == 'ref' %}
- {% if obj.data(fieldn) is iterable %}
- <li>{{ fieldn }}
- {% set l_classe = fieldv.allowed_classes[0] %}
- <ul>
- {% for rel in obj.data(fieldn) %}
- {% set casttype = l_classe.data_handler(l_classe.uid_fieldname()[0]).cast_type %}
- {% set linked_object = l_classe.get(('%s = %s') % (l_classe.uid_fieldname()[0], rel)) %}
- {% set rel2 = casttype(rel) %}
- <li><a href="show_object_detailled?classname={{ l_classe.__name__ }}&lodel_id={{ rel2 }}" >{{ rel2 }}</a></li>
- {% endfor %}
- </ul></li>
- {% endif %}
- {% else %}
- <li> {{ fieldn }} : {{ obj.data(fieldn) }} </li>
- {% endif %}
- {% endif %}
- {% endfor %}
- {%- endmacro %}
-
|