Projet

Général

Profil

0001-toulouse_smart-rename-wcs-field-labels-using-display.patch

Nicolas Roche (absent jusqu'au 3 avril), 19 juillet 2021 15:41

Télécharger (4,48 ko)

Voir les différences:

Subject: [PATCH] toulouse_smart: rename wcs field labels using displayName
 property (#55513)

 .../templates/toulouse_smart/wcs_block.wcs               | 2 +-
 tests/test_toulouse_smart.py                             | 9 ++++++---
 2 files changed, 7 insertions(+), 4 deletions(-)
passerelle/contrib/toulouse_smart/templates/toulouse_smart/wcs_block.wcs
1 1
<?xml version="1.0"?>
2 2
<block id="{{ id }}">
3 3
  <name>{{ name }}</name>
4 4
  <slug>{{ name|slugify }}</slug>
5 5
  <fields>{% for property in properties %}
6 6
    <field>
7 7
      <id>{{ property.id }}</id>
8
      <label>{{ property.name }}</label>
8
      <label>{{ property.displayName }}</label>
9 9
      <type>{{ property.type }}</type>
10 10
      <required>{{ property.required }}</required>
11 11
      <varname>{{ property.name|slugify }}</varname>
12 12
      <display_locations>
13 13
        <display_location>validation</display_location>
14 14
        <display_location>summary</display_location>
15 15
      </display_locations>{% if property.validation %}
16 16
      <validation>
tests/test_toulouse_smart.py
75 75

  
76 76
INTERVENTION_TYPES = '''<List>
77 77
   <item>
78 78
       <id>1234</id>
79 79
       <name>coin</name>
80 80
       <properties>
81 81
           <properties>
82 82
              <name>FIELD1</name>
83
              <displayName>Champ 1</displayName>
83 84
              <type>string</type>
84 85
              <required>false</required>
85 86
              <defaultValue>Ne sait pas</defaultValue>
86 87
              <restrictedValues>
87 88
                <restrictedValues>Candélabre</restrictedValues>
88 89
                <restrictedValues>Mât</restrictedValues>
89 90
                <restrictedValues>Ne sait pas</restrictedValues>
90 91
              </restrictedValues>
91 92
           </properties>
92 93
           <properties>
93 94
              <name>FIELD2</name>
95
              <displayName>Champ 2</displayName>
94 96
              <type>int</type>
95 97
              <required>true</required>
96 98
           </properties>
97 99
       </properties>
98 100
   </item>
99 101
</List>'''.encode()
100 102

  
101 103

  
......
104 106
    assert smart.get_intervention_types() == [
105 107
        {
106 108
            'id': '1234',
107 109
            'name': 'coin',
108 110
            'order': 1,
109 111
            'properties': [
110 112
                {
111 113
                    'name': 'FIELD1',
114
                    'displayName': 'Champ 1',
112 115
                    'required': False,
113 116
                    'type': 'item',
114 117
                    'defaultValue': 'Ne sait pas',
115 118
                    'restrictedValues': ['Candélabre', 'Mât', 'Ne sait pas'],
116 119
                },
117
                {'name': 'FIELD2', 'required': True, 'type': 'int'},
120
                {'name': 'FIELD2', 'displayName': 'Champ 2', 'required': True, 'type': 'int'},
118 121
            ],
119 122
        },
120 123
    ]
121 124

  
122 125

  
123 126
URL = '/toulouse-smart/test/'
124 127

  
125 128

  
......
153 156
            assert (
154 157
                content
155 158
                == '''<block id="1234">
156 159
  <name>coin</name>
157 160
  <slug>coin</slug>
158 161
  <fields>
159 162
    <field>
160 163
      <id>038a8c2e-14de-4d4f-752f-496eb7fe90d7</id>
161
      <label>FIELD1</label>
164
      <label>Champ 1</label>
162 165
      <type>item</type>
163 166
      <required>False</required>
164 167
      <varname>field1</varname>
165 168
      <display_locations>
166 169
        <display_location>validation</display_location>
167 170
        <display_location>summary</display_location>
168 171
      </display_locations>
169 172
      <items>
170 173
        <item>Cand&#233;labre</item>
171 174
        <item>M&#226;t</item>
172 175
        <item>Ne sait pas</item>
173 176
      </items>
174 177
    </field>
175 178
    <field>
176 179
      <id>e72f251a-5eef-5b78-c35a-94b549510029</id>
177
      <label>FIELD2</label>
180
      <label>Champ 2</label>
178 181
      <type>string</type>
179 182
      <required>True</required>
180 183
      <varname>field2</varname>
181 184
      <display_locations>
182 185
        <display_location>validation</display_location>
183 186
        <display_location>summary</display_location>
184 187
      </display_locations>
185 188
      <validation>
186
-