equal
deleted
inserted
replaced
2 # original code: http://trac.pyworks.org/pyjamas/wiki/DjangoWithPyJamas |
2 # original code: http://trac.pyworks.org/pyjamas/wiki/DjangoWithPyJamas |
3 # also from: http://www.pimentech.fr/technologies/outils |
3 # also from: http://www.pimentech.fr/technologies/outils |
4 |
4 |
5 from __future__ import absolute_import |
5 from __future__ import absolute_import |
6 import datetime |
6 import datetime |
|
7 from builtins import str as text |
7 |
8 |
8 from django.core.serializers import serialize |
9 from django.core.serializers import serialize |
9 |
10 |
10 |
11 |
11 from svgui.pyjs.jsonrpc.jsonrpc import JSONRPCServiceBase |
12 from svgui.pyjs.jsonrpc.jsonrpc import JSONRPCServiceBase |
72 d = {} |
73 d = {} |
73 for error in form.errors.keys(): |
74 for error in form.errors.keys(): |
74 if error not in d: |
75 if error not in d: |
75 d[error] = [] |
76 d[error] = [] |
76 for errorval in form.errors[error]: |
77 for errorval in form.errors[error]: |
77 d[error].append(unicode(errorval)) |
78 d[error].append(text(errorval)) |
78 return d |
79 return d |
79 |
80 |
80 |
81 |
81 # contains the list of arguments in each field |
82 # contains the list of arguments in each field |
82 field_names = { |
83 field_names = { |
99 def describe_field_errors(field): |
100 def describe_field_errors(field): |
100 res = {} |
101 res = {} |
101 field_type = field.__class__.__name__ |
102 field_type = field.__class__.__name__ |
102 msgs = {} |
103 msgs = {} |
103 for n, m in field.error_messages.items(): |
104 for n, m in field.error_messages.items(): |
104 msgs[n] = unicode(m) |
105 msgs[n] = text(m) |
105 res['error_messages'] = msgs |
106 res['error_messages'] = msgs |
106 if field_type in ['ComboField', 'MultiValueField', 'SplitDateTimeField']: |
107 if field_type in ['ComboField', 'MultiValueField', 'SplitDateTimeField']: |
107 res['fields'] = map(describe_field, field.fields) |
108 res['fields'] = map(describe_field, field.fields) |
108 return res |
109 return res |
109 |
110 |