Sapan Bhatia | d022aeb | 2017-06-07 15:49:55 +0200 | [diff] [blame] | 1 | items: |
| 2 | {%- for m in proto.messages | sort(attribute='name') %} |
Matteo Scandolo | 5341859 | 2017-07-26 15:51:29 -0700 | [diff] [blame] | 3 | {%- if m.name != 'XOSBase' and xproto_unquote(xproto_first_non_empty([m.options.gui_hidden, 'False'])) != 'True' %} |
Sapan Bhatia | aef145d | 2017-07-10 19:52:09 -0400 | [diff] [blame] | 4 | - app: {{ xproto_unquote(xproto_first_non_empty([m.options.name, m.options.app_label, options.name, context.app_label])) }} |
Sapan Bhatia | d022aeb | 2017-06-07 15:49:55 +0200 | [diff] [blame] | 5 | fields: |
| 6 | {%- set id_field = {'type':'int32', 'name':'id', 'options':{}} %} |
| 7 | {% for f in (xproto_base_fields(m, proto.message_table) + m.fields + [id_field]) | sort(attribute='name') -%} |
Matteo Scandolo | 5341859 | 2017-07-26 15:51:29 -0700 | [diff] [blame] | 8 | {% if xproto_unquote(xproto_first_non_empty([f.options.gui_hidden, 'False'])) != 'True' and (not f.link or f.options.link_type != 'manytomany') -%} |
Sapan Bhatia | d022aeb | 2017-06-07 15:49:55 +0200 | [diff] [blame] | 9 | - hint: {% if f.options.help_text %}{{ xproto_unquote(f.options.help_text) }}{% else %}''{% endif %} |
| 10 | {% if not f.link -%} |
| 11 | name: {{ f.name }} |
| 12 | {%- else -%} |
| 13 | name: {{ f.name }}_id |
| 14 | relation: {model: {{ f.options.model }}, type: {{ f.options.link_type }}} |
| 15 | {% endif %} |
Matteo Scandolo | 292cc2a | 2017-07-31 19:02:12 -0700 | [diff] [blame] | 16 | {%- if f.options.default %} |
| 17 | default: "{{ xproto_unquote(xproto_default_to_gui(f.options.default)) }}" |
| 18 | {%- endif %} |
| 19 | {%- if f.options.choices %} |
| 20 | options: |
| 21 | {% for o in xproto_options_choices_to_dict(xproto_unquote(f.options.choices)) %} |
| 22 | - {{ o }} |
| 23 | {% endfor %} |
| 24 | {%- endif %} |
Sapan Bhatia | d022aeb | 2017-06-07 15:49:55 +0200 | [diff] [blame] | 25 | type: {{ xproto_type_to_ui_type(f) }} |
| 26 | {% set validators = xproto_validators(f) -%} |
| 27 | {% if validators -%} |
| 28 | validators: |
| 29 | {% for v in validators | sort(attribute='name',reverse=True) -%} |
| 30 | - {{ v | yaml }} |
| 31 | {% endfor %} |
| 32 | {% else -%} |
| 33 | validators: [] |
| 34 | {% endif %} |
| 35 | {% endif -%} |
| 36 | {% endfor %} |
Matteo Scandolo | 292cc2a | 2017-07-31 19:02:12 -0700 | [diff] [blame] | 37 | name: {{ m.name }} |
Matteo Scandolo | 1f826a4 | 2017-08-02 12:02:02 -0700 | [diff] [blame^] | 38 | {%- set goodlinks = xproto_links_to_modeldef_relations( xproto_base_links(m, proto.message_table) + m.links ) + xproto_links_to_modeldef_relations( xproto_base_rlinks(m, proto.message_table) + m.rlinks )%} |
Sapan Bhatia | d022aeb | 2017-06-07 15:49:55 +0200 | [diff] [blame] | 39 | {% if goodlinks %} |
| 40 | relations: |
| 41 | {{ goodlinks | join('\n') | indent(width=2)}} |
| 42 | {%- else %} |
| 43 | relations: [] |
| 44 | {%- endif %} |
| 45 | {%- endif %} |
| 46 | {% endfor -%} |