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.

show_object.html 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. <!-- Produce a <li></li> with objects informations -->
  16. {% macro object_ul(leo, max_depth = 0, exclude = []) -%}
  17. <ul>
  18. {% if max_depth <= 0 %}
  19. <!-- No need to go deeper -->
  20. {% for fname, fvalue in leo.datas(True).items() %}
  21. <li><em>{{ fname }}</em> : {{fvalue}}</li>
  22. {%endfor%}
  23. {% else %}
  24. {% for fname in leo.fieldnames(True) %}
  25. {% set fvalue = leo.data(fname) %}
  26. {% set fdh = leo.data_handler(fname) %}
  27. {% if fvalue is not none and fdh.is_reference() %}
  28. {% if fdh.is_singlereference() %}
  29. {% set referenced = fdh.get_referenced(fvalue) %}
  30. {% if (referenced.__class__.__name__, referenced.uid) in exclude %}
  31. <li><em>{{fname}}</em> : {{fvalue}}</li>
  32. {% else %}
  33. <li><em>{{fname}}</em> : {{object_ul(referenced, max_depth - 1, exclude + [(leo.__class__.__name__, leo.uid())] )}}</li>
  34. {% endif %}
  35. {% else %}
  36. <li><em>{{fname}}</em> : <ul>
  37. {% for referenced in fdh.get_referenced(fvalue) %}
  38. {% if (referenced.__class__.__name__, referenced.uid) in exclude %}
  39. <li><em>{{fname}}</em> : {{fvalue}}</li>
  40. {% else %}
  41. <li><em>{{fname}}</em> : {{object_ul(referenced, max_depth - 1, exclude + [(leo.__class__.__name__, leo.uid())] )}}</li>
  42. {% endif %}
  43. {% endfor %}
  44. </ul></li>
  45. {% endif %}
  46. {% else %}
  47. <li><em>{{fname}}</em> : {{fvalue}}</li>
  48. {% endif %}
  49. {% endfor %}
  50. {% endif %}
  51. </ul>
  52. {%- endmacro %}