Commit 4db8a436 by David Robinson

Merge pull request #87 from mcastle/user_relations

Handle adding and removing relations by User.
parents ba9b2f65 d9506152
......@@ -114,5 +114,27 @@ class User(ParseResource):
def __repr__(self):
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)
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