Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8f3f0b1

Browse files
committed
fix "NameError: name 'model' is not defined"; add 1 test case
1 parent0fb0711 commit8f3f0b1

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

‎tests/test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,19 @@ def test_apijson_get():
414414
>>> print(d)
415415
{'code': 400, 'msg': "'publicnotice' cannot filter with owner"}
416416
417+
>>> #query array with OWNER
418+
>>> data ='''{
419+
... "[]":{
420+
... "comment": {
421+
... "@role":"OWNER"
422+
... }
423+
... }
424+
... }'''
425+
>>> r = handler.post('/apijson/get', data=data, pre_call=pre_call_as("admin"), middlewares=[])
426+
>>> d = json_loads(r.data)
427+
>>> print(d)
428+
{'code': 200, 'msg': 'success', '[]': [{'comment': {'user_id': 1, 'to_id': 3, 'moment_id': 1, 'date': '2018-11-01 00:00:00', 'content': 'comment from admin', 'id': 1}}]}
429+
417430
>>> #Association query: Two tables, one to one,ref path is absolute path
418431
>>> data ='''{
419432
... "moment":{},

‎uliweb_apijson/apijson/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,12 @@ def _get_array_params(self):
145145
def_filter_owner(self,q):
146146
owner_filtered=False
147147
ifhasattr(self.model,"owner_condition"):
148-
q=q.filter(model.owner_condition())
148+
q=q.filter(self.model.owner_condition(request.user.id))
149149
owner_filtered=True
150150
ifnotowner_filtered:
151151
user_id_field=self.setting.get("user_id_field")
152152
ifuser_id_field:
153-
q=q.filter(getattr(model.c,user_id_field)==request.user.id)
153+
q=q.filter(getattr(self.model.c,user_id_field)==request.user.id)
154154
owner_filtered=True
155155
ifnotowner_filtered:
156156
raiseUliwebError("'%s' cannot filter with owner"%(self.name))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp