Commit d9506152 by Marlon

Handle adding and removing relations by User.

parent ba9b2f65
...@@ -114,5 +114,27 @@ class User(ParseResource): ...@@ -114,5 +114,27 @@ class User(ParseResource):
def __repr__(self): def __repr__(self):
return '<User:%s (Id %s)>' % (getattr(self, 'username', None), self.objectId) return '<User:%s (Id %s)>' % (getattr(self, 'username', None), self.objectId)
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] = ''
User.Query = QueryManager(User) User.Query = QueryManager(User)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment