Skip to content

Commit 6f8cade

Browse files
committed
apison_post: modify to be same with original apijson, just return "id" and "count", not other fields
1 parent bb4eeb0 commit 6f8cade

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

Diff for: tests/test.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -950,9 +950,8 @@ def test_apijson_post():
950950
... }'''
951951
>>> r = handler.post('/apijson/post', data=data, pre_call=pre_call_as("admin"), middlewares=[])
952952
>>> d = json_loads(r.data)
953-
>>> del d['moment']['date']
954953
>>> print(d)
955-
{'code': 200, 'msg': 'success', 'moment': {'user_id': 1, 'content': 'new moment for test', 'picture_list': ['http://static.oschina.net/uploads/user/48/96331_50.jpg'], 'id': 4, 'code': 200, 'message': 'success'}}
954+
{'code': 200, 'msg': 'success', 'moment': {'id': 4, 'count': 1, 'code': 200, 'message': 'success'}}
956955
957956
>>> #apijson post to a non exist model
958957
>>> data ='''{

Diff for: uliweb_apijson/apijson/views.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -422,13 +422,12 @@ def _post_one(self,key,tag):
422422

423423
obj = model(**params)
424424
ret = obj.save()
425-
obj_dict = obj.to_dict(convert=False)
426-
secret_fields = model_setting.get("secret_fields")
427-
if secret_fields:
428-
for k in secret_fields:
429-
del obj_dict[k]
425+
d = obj.to_dict(convert=False)
430426

427+
obj_dict = {}
431428
if ret:
429+
obj_dict["id"] = d.get("id")
430+
obj_dict["count"] = 1
432431
obj_dict["code"] = 200
433432
obj_dict["message"] = "success"
434433
else:

0 commit comments

Comments
 (0)