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])) }} |
Matteo Scandolo | e425f9d | 2017-08-15 15:56:19 -0700 | [diff] [blame] | 5 | {%- if m.options.description %} |
| 6 | description: "{{ xproto_unquote(m.options.description) }}" |
| 7 | {%- endif %} |
| 8 | {%- if m.options.verbose_name %} |
| 9 | verbose_name: "{{ xproto_unquote(m.options.verbose_name) }}" |
| 10 | {%- endif %} |
Sapan Bhatia | d022aeb | 2017-06-07 15:49:55 +0200 | [diff] [blame] | 11 | fields: |
| 12 | {%- set id_field = {'type':'int32', 'name':'id', 'options':{}} %} |
| 13 | {% 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] | 14 | {% 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] | 15 | - hint: {% if f.options.help_text %}{{ xproto_unquote(f.options.help_text) }}{% else %}''{% endif %} |
| 16 | {% if not f.link -%} |
| 17 | name: {{ f.name }} |
| 18 | {%- else -%} |
| 19 | name: {{ f.name }}_id |
| 20 | relation: {model: {{ f.options.model }}, type: {{ f.options.link_type }}} |
| 21 | {% endif %} |
Matteo Scandolo | 292cc2a | 2017-07-31 19:02:12 -0700 | [diff] [blame] | 22 | {%- if f.options.default %} |
| 23 | default: "{{ xproto_unquote(xproto_default_to_gui(f.options.default)) }}" |
| 24 | {%- endif %} |
| 25 | {%- if f.options.choices %} |
| 26 | options: |
| 27 | {% for o in xproto_options_choices_to_dict(xproto_unquote(f.options.choices)) %} |
| 28 | - {{ o }} |
| 29 | {% endfor %} |
| 30 | {%- endif %} |
Sapan Bhatia | d022aeb | 2017-06-07 15:49:55 +0200 | [diff] [blame] | 31 | type: {{ xproto_type_to_ui_type(f) }} |
Matteo Scandolo | 23cf15f | 2018-03-06 18:12:36 -0800 | [diff] [blame] | 32 | read_only: {{ xproto_is_true(f.options.feedback_state) }} |
Sapan Bhatia | d022aeb | 2017-06-07 15:49:55 +0200 | [diff] [blame] | 33 | {% set validators = xproto_validators(f) -%} |
| 34 | {% if validators -%} |
| 35 | validators: |
| 36 | {% for v in validators | sort(attribute='name',reverse=True) -%} |
| 37 | - {{ v | yaml }} |
| 38 | {% endfor %} |
| 39 | {% else -%} |
| 40 | validators: [] |
| 41 | {% endif %} |
| 42 | {% endif -%} |
| 43 | {% endfor %} |
Matteo Scandolo | 292cc2a | 2017-07-31 19:02:12 -0700 | [diff] [blame] | 44 | name: {{ m.name }} |
Matteo Scandolo | 1f826a4 | 2017-08-02 12:02:02 -0700 | [diff] [blame] | 45 | {%- 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] | 46 | {% if goodlinks %} |
| 47 | relations: |
| 48 | {{ goodlinks | join('\n') | indent(width=2)}} |
| 49 | {%- else %} |
| 50 | relations: [] |
| 51 | {%- endif %} |
| 52 | {%- endif %} |
| 53 | {% endfor -%} |