0001-atal-switch-comment-variables-names-37904.patch
passerelle/apps/atal/models.py | ||
---|---|---|
223 | 223 |
raise APIError('Could not get a status') |
224 | 224 | |
225 | 225 |
responses = (demand_details.get('reponses') or {}).get('Reponse') or [] |
226 |
demand_comments = []
|
|
226 |
works_comments = []
|
|
227 | 227 |
if responses: |
228 | 228 |
for response in responses: |
229 | 229 |
comment = { |
... | ... | |
232 | 232 |
} |
233 | 233 |
if 'dateReponse' in response: |
234 | 234 |
comment['date'] = dateformat.format(response['dateReponse'], DATE_FORMAT) |
235 |
demand_comments.append(comment)
|
|
235 |
works_comments.append(comment)
|
|
236 | 236 | |
237 |
demand_comment = {
|
|
237 |
works_comment = {
|
|
238 | 238 |
'text': None, |
239 | 239 |
'date': None |
240 | 240 |
} |
241 |
if demand_comments:
|
|
242 |
demand_comment = demand_comments[-1]
|
|
241 |
if works_comments:
|
|
242 |
works_comment = works_comments[-1]
|
|
243 | 243 | |
244 | 244 |
data = { |
245 | 245 |
'status': status, |
246 |
'demand_comment': demand_comment,
|
|
246 |
'works_comment': works_comment,
|
|
247 | 247 |
'demand_details': None, |
248 |
'demand_comments': []
|
|
248 |
'works_comments': []
|
|
249 | 249 |
} |
250 | 250 |
if full: |
251 | 251 |
data['demand_details'] = demand_details |
252 |
data['demand_comments'] = demand_comments
|
|
252 |
data['works_comments'] = works_comments
|
|
253 | 253 | |
254 | 254 |
if status not in ('PRISE EN COMPTE', 'ARCHIVEE'): |
255 | 255 |
return { |
... | ... | |
267 | 267 |
raise APIError('Could not get a status') |
268 | 268 | |
269 | 269 |
data['status'] = status |
270 |
data['works_comment'] = works_status.get('commentaires', '')
|
|
270 |
data['demand_comment'] = works_status.get('commentaires', '')
|
|
271 | 271 |
data['works_status'] = None |
272 | 272 | |
273 | 273 |
if full: |
tests/test_atal.py | ||
---|---|---|
298 | 298 |
assert response.json['err'] == 0 |
299 | 299 |
data = response.json['data'] |
300 | 300 |
assert data['status'] == u'travaux pas commencés' |
301 |
assert data['demand_comment'] == {
|
|
301 |
assert data['works_comment'] == {
|
|
302 | 302 |
'text': 'bonjour atal', |
303 | 303 |
'date': 'Thursday 24 October 2019, 16:51' |
304 | 304 |
} |
305 |
assert data['demand_comments'] == []
|
|
306 |
assert data['works_comment'] is None
|
|
305 |
assert data['works_comments'] == []
|
|
306 |
assert data['demand_comment'] is None
|
|
307 | 307 |
assert data['works_status'] is None |
308 | 308 | |
309 | 309 |
# full in query string |
... | ... | |
312 | 312 |
) |
313 | 313 |
response = app.get('/atal/slug-atal/infos/DIT18050001/?full=true') |
314 | 314 |
data = response.json['data'] |
315 |
assert len(data['demand_comments']) == 2
|
|
316 |
assert data['demand_comments'][0] == {
|
|
315 |
assert len(data['works_comments']) == 2
|
|
316 |
assert data['works_comments'][0] == {
|
|
317 | 317 |
'text': 'OK', |
318 | 318 |
'date': 'Thursday 24 October 2019, 16:48' |
319 | 319 |
} |
... | ... | |
321 | 321 |
'text': 'bonjour atal', |
322 | 322 |
'date': 'Thursday 24 October 2019, 16:51' |
323 | 323 |
} |
324 |
assert data['demand_comments'][1] == last_comment |
|
325 |
assert data['demand_comment'] == last_comment |
|
324 |
assert data['works_comments'][1] == last_comment |
|
325 |
assert data['works_comment'] == last_comment |
|
326 |
- |