0001-misc-allow-pattern-description-in-json-schemas-54663.patch
passerelle/apps/cmis/models.py | ||
---|---|---|
55 | 55 |
'properties': { |
56 | 56 |
'filename': { |
57 | 57 |
'type': 'string', |
58 |
'description': _('Filename (numbers, letters and special caracters "%s" are allowed)') |
|
59 |
% SPECIAL_CHARS, |
|
58 |
'description': _('Filename'), |
|
60 | 59 |
'pattern': FILE_NAME_PATTERN, |
60 |
'pattern_description': _('Numbers, letters and special caracters "%s" are allowed.') |
|
61 |
% SPECIAL_CHARS, |
|
61 | 62 |
}, |
62 | 63 |
'content': { |
63 | 64 |
'type': 'string', |
... | ... | |
74 | 75 |
'type': 'string', |
75 | 76 |
'description': _('Filename (takes precendence over filename in "file" object)'), |
76 | 77 |
'pattern': FILE_NAME_PATTERN, |
78 |
'pattern_description': _('Numbers, letters and special caracters "%s" are allowed.') |
|
79 |
% SPECIAL_CHARS, |
|
77 | 80 |
}, |
78 | 81 |
'path': { |
79 | 82 |
'type': 'string', |
80 |
'description': _('File path (with leading but not trailing slash)'),
|
|
83 |
'description': _('File path'), |
|
81 | 84 |
'pattern': FILE_PATH_PATTERN, |
85 |
'pattern_description': _('Must include leading but not trailing slash.'), |
|
82 | 86 |
}, |
83 | 87 |
'object_type': { |
84 | 88 |
'type': 'string', |
passerelle/base/templatetags/passerelle.py | ||
---|---|---|
158 | 158 |
min_length = schema.pop('minLength', '') |
159 | 159 |
max_length = schema.pop('maxLength', '') |
160 | 160 |
pattern = schema.pop('pattern', '') |
161 |
pattern_description = schema.pop('pattern_description', '') |
|
161 | 162 |
if enum: |
162 | 163 |
enum = mark_safe(' | '.join([format_html('<tt>{}</tt>', json.dumps(el)) for el in enum])) |
163 | 164 |
s = 'string' |
... | ... | |
166 | 167 |
s = html_type(s) |
167 | 168 |
if enum: |
168 | 169 |
s += ' %s' % enum |
169 |
if pattern: |
|
170 |
if pattern_description: |
|
171 |
s += format_html(' <em>{}</em>', pattern_description) |
|
172 |
elif pattern: |
|
170 | 173 |
s += format_html(' /<tt>{}</tt>/', pattern) |
171 | 174 |
if schema: |
172 | 175 |
s += format_html('\n{!r}', schema) |
passerelle/contrib/caluire_axel/schemas.py | ||
---|---|---|
30 | 30 |
{ |
31 | 31 |
'type': 'string', |
32 | 32 |
'pattern': '[Oo]|[Nn]|[Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee]|1|0', |
33 |
'pattern_description': 'Les valeurs "0", "1", "O", "N", "true" ou "false" sont autorisées.', |
|
33 | 34 |
}, |
34 | 35 |
] |
35 | 36 |
} |
passerelle/contrib/toulouse_smart/schemas.py | ||
---|---|---|
14 | 14 |
# You should have received a copy of the GNU Affero General Public License |
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | |
17 | ||
18 | 17 |
BOOLEAN_TYPES = [ |
19 | 18 |
{'type': 'boolean'}, |
20 | 19 |
{ |
21 | 20 |
'type': 'string', |
22 | 21 |
'pattern': '[Oo][Uu][Ii]|[Nn][Oo][Nn]|[Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee]|1|0', |
22 |
'pattern_description': 'Les valeurs "0", "1", "true", "false", "oui" ou "non" sont autorisées.', |
|
23 | 23 |
}, |
24 | 24 |
] |
25 | 25 |
tests/test_templatetags.py | ||
---|---|---|
69 | 69 |
str(render_json_schema({'enum': [1, "aaa", [1]]})) |
70 | 70 |
== '<tt>1</tt> | <tt>"aaa"</tt> | <tt>[1]</tt>' |
71 | 71 |
) |
72 | ||
73 | ||
74 |
def test_render_pattern_description(): |
|
75 |
schema = {'type': 'object', 'properties': {'filename': {'type': 'string', 'pattern': 'abc'}}} |
|
76 |
assert 'abc' in render_json_schema(schema) |
|
77 | ||
78 |
schema['properties']['filename']['pattern_description'] = 'efg' |
|
79 |
assert 'abc' not in render_json_schema(schema) and 'efg' in render_json_schema(schema) |
|
72 |
- |