No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

display_obj.html 1.9KB

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