0001-mdel_ddpacs-preprocess-create-requests-39839.patch
passerelle/apps/mdel_ddpacs/abstract.py | ||
---|---|---|
123 | 123 |
'code_insee': {'type': 'string'}, |
124 | 124 |
}) |
125 | 125 |
base_schema.setdefault('required', []).append('display_id') |
126 |
if hasattr(cls, 'pre_process_create'): |
|
127 |
base_schema['pre_process'] = cls.pre_process_create |
|
126 | 128 |
return base_schema |
127 | 129 | |
128 | 130 |
def _handle_create(self, request, payload): |
passerelle/apps/mdel_ddpacs/models.py | ||
---|---|---|
102 | 102 |
def create(self, request, post_data): |
103 | 103 |
return self._handle_create(request, post_data) |
104 | 104 | |
105 |
def pre_process_create(self, data): |
|
106 |
def helper(d): |
|
107 |
if not isinstance(d, dict): |
|
108 |
return |
|
109 |
# choose between conventionType and conventionSpecifique |
|
110 |
if 'conventionSpecifique' in d: |
|
111 |
if d['conventionSpecifique']: |
|
112 |
d.pop('conventionType', None) |
|
113 |
else: |
|
114 |
del d['conventionSpecifique'] |
|
115 |
# choose between filiationInconnu and filiationConnu |
|
116 |
if 'filiationInconnu' in d: |
|
117 |
if d['filiationInconnu']: |
|
118 |
d.pop('filiationConnu', None) |
|
119 |
else: |
|
120 |
del d['filiationInconnu'] |
|
121 |
# convert codeNationalite to array of strings |
|
122 |
if isinstance(d.get('codeNationalite'), six.text_type)): |
|
123 |
d['codeNationalite'] = [d['codeNationalite']] |
|
124 |
for key in d: |
|
125 |
helper(d[key]) |
|
126 |
helper(data) |
|
127 | ||
105 | 128 |
Resource.create.endpoint_info.post['request_body']['schema']['application/json'] = Resource.get_create_schema() |
106 | 129 | |
107 | 130 | |
108 |
- |