Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
ParsePy
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ParsePy
Commits
3ace526b
Commit
3ace526b
authored
Jan 21, 2014
by
Rafael Bermúdez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add, Remove, and query Relations
parent
9e9bbd29
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
2 deletions
+28
-2
parse_rest/datatypes.py
+23
-0
parse_rest/query.py
+5
-2
No files found.
parse_rest/datatypes.py
View file @
3ace526b
...
@@ -367,3 +367,25 @@ class Object(ParseResource):
...
@@ -367,3 +367,25 @@ class Object(ParseResource):
}
}
self
.
__class__
.
PUT
(
self
.
_absolute_url
,
**
payload
)
self
.
__class__
.
PUT
(
self
.
_absolute_url
,
**
payload
)
self
.
__dict__
[
key
]
+=
amount
self
.
__dict__
[
key
]
+=
amount
def
removeRelation
(
self
,
key
,
className
,
objectsId
):
self
.
manageRelation
(
'RemoveRelation'
,
key
,
className
,
objectsId
)
def
addRelation
(
self
,
key
,
className
,
objectsId
):
self
.
manageRelation
(
'AddRelation'
,
key
,
className
,
objectsId
)
def
manageRelation
(
self
,
action
,
key
,
className
,
objectsId
):
objects
=
[{
"__type"
:
"Pointer"
,
"className"
:
className
,
"objectId"
:
objectId
}
for
objectId
in
objectsId
]
payload
=
{
key
:
{
"__op"
:
action
,
"objects"
:
objects
}
}
self
.
__class__
.
PUT
(
self
.
_absolute_url
,
**
payload
)
self
.
__dict__
[
key
]
=
''
\ No newline at end of file
parse_rest/query.py
View file @
3ace526b
...
@@ -77,7 +77,7 @@ class Queryset(object):
...
@@ -77,7 +77,7 @@ class Queryset(object):
__metaclass__
=
QuerysetMetaclass
__metaclass__
=
QuerysetMetaclass
OPERATORS
=
[
OPERATORS
=
[
'lt'
,
'lte'
,
'gt'
,
'gte'
,
'ne'
,
'in'
,
'nin'
,
'exists'
,
'select'
,
'dontSelect'
,
'all'
'lt'
,
'lte'
,
'gt'
,
'gte'
,
'ne'
,
'in'
,
'nin'
,
'exists'
,
'select'
,
'dontSelect'
,
'all'
,
'relatedTo'
]
]
@staticmethod
@staticmethod
...
@@ -123,7 +123,10 @@ class Queryset(object):
...
@@ -123,7 +123,10 @@ class Queryset(object):
if
operator
is
None
:
if
operator
is
None
:
self
.
_where
[
attr
]
=
parse_value
self
.
_where
[
attr
]
=
parse_value
else
:
else
:
self
.
_where
[
attr
][
'$'
+
operator
]
=
parse_value
if
operator
==
'relatedTo'
:
self
.
_where
[
'$'
+
operator
]
=
parse_value
else
:
self
.
_where
[
attr
][
'$'
+
operator
]
=
parse_value
return
self
return
self
def
order_by
(
self
,
order
,
descending
=
False
):
def
order_by
(
self
,
order
,
descending
=
False
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment