0001-wip-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 |
del d['conventionSpecifique'] |
|
113 |
else: |
|
114 |
d.pop('conventionType', None) |
|
115 |
# choose between filiationInconnu and filiationConnu |
|
116 |
if 'filiationInconnu' in d: |
|
117 |
if d['filiationInconnu'] == '': |
|
118 |
del d['filiationInconnu'] |
|
119 |
else: |
|
120 |
d.pop('filiationConnu', None) |
|
121 |
for key in d: |
|
122 |
helper(d[key]) |
|
123 |
helper(data) |
|
124 | ||
105 | 125 |
Resource.create.endpoint_info.post['request_body']['schema']['application/json'] = Resource.get_create_schema() |
106 | 126 | |
107 | 127 | |
108 |
- |