Add function to delete post
authorMoritz Kiefer <moritz.kiefer@gmail.com>
Sat, 2 Feb 2013 21:40:13 +0000 (22:40 +0100)
committerMoritz Kiefer <moritz.kiefer@gmail.com>
Sat, 2 Feb 2013 21:40:13 +0000 (22:40 +0100)
diaspy/models.py

index 526d50113e965fbd4b634b7b66659515e779de4d..20001cee59f7fb6a90bb8606d53afaeb02d424ed 100644 (file)
@@ -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