From 5e809c8bf1104c6bbef55922abfdaffb694f9b9c Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Sat, 2 Feb 2013 22:40:13 +0100 Subject: [PATCH] Add function to delete post --- diaspy/models.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/diaspy/models.py b/diaspy/models.py index 526d501..20001ce 100644 --- a/diaspy/models.py +++ b/diaspy/models.py @@ -56,7 +56,7 @@ class Post: return r.json() - def rmlike(self): + def delete_like(self): """This function removes a like from a post """ @@ -123,7 +123,7 @@ class Post: return r.json() - def rmcomment(self, comment_id): + def delete_comment(self, comment_id): """This function removes a comment from a post :param post_id: id of the post to remove the like from. @@ -145,3 +145,17 @@ class Post: if r.status_code != 204: raise Exception(str(r.status_code) + ': Comment could not be deleted.') + + def delete(self): + """ This function deletes this post + + """ + + data = {'authenticity_token': self._client.get_token()} + + r = self._client.session.delete(self._client.pod + '/posts/' + + self.post_id, + data=data, + headers={'accept': 'application/json'}) + + return r -- 2.25.1