Err, it was kinda stupid to return anything about *deleted* stuff,
authorMarek Marecki <marekjm@taistelu.com>
Thu, 8 Aug 2013 16:23:42 +0000 (18:23 +0200)
committerMarek Marecki <marekjm@taistelu.com>
Thu, 8 Aug 2013 16:23:42 +0000 (18:23 +0200)
removed it

diaspy/models.py
logger.py [new file with mode: 0644]

index 0c5f4f2c236f6c8c6f32a57516eb3e9e61c617fe..1d0156f06c469c82287371b54151961b492d276c 100644 (file)
@@ -1,17 +1,17 @@
 #!/usr/bin/env python3
 
 
+"""This module is only imported in other diaspy modules and
+MUST NOT import anything.
+"""
+
+
 import json
 import re
 
 from diaspy import errors
 
 
-"""This module is only imported in other diaspy modules and
-MUST NOT import anything.
-"""
-
-
 class Aspect():
     """This class represents an aspect.
 
@@ -316,20 +316,6 @@ class Post():
                             .format(request.status_code))
         return request.json()
 
-    def delete_like(self):
-        """This function removes a like from a post
-        """
-        data = {'authenticity_token': self._connection.get_token()}
-
-        request = self._connection.delete('posts/{0}/likes/{1}'
-                                    .format(self.id,
-                                            self.data['interactions']
-                                                     ['likes'][0]['id']),
-                                    data=data)
-        if request.status_code != 204:
-            raise errors.PostError('{0}: Like could not be removed.'
-                            .format(request.status_code))
-
     def reshare(self):
         """This function reshares a post
         """
@@ -360,6 +346,16 @@ class Post():
                             .format(request.status_code))
         return request.json()
 
+    def delete(self):
+        """ This function deletes this post
+        """
+        data = {'authenticity_token': repr(self._connection)}
+        request = self._connection.delete('posts/{0}'.format(self.id),
+                                    data=data,
+                                    headers={'accept': 'application/json'})
+        if request.status_code != 204:
+            raise errors.PostError('{0}: Post could not be deleted'.format(request.status_code))
+
     def delete_comment(self, comment_id):
         """This function removes a comment from a post
 
@@ -376,17 +372,20 @@ class Post():
         if request.status_code != 204:
             raise errors.PostError('{0}: Comment could not be deleted'
                             .format(request.status_code))
-        return request.status_code
 
-    def delete(self):
-        """ This function deletes this post
+    def delete_like(self):
+        """This function removes a like from a post
         """
-        data = {'authenticity_token': repr(self._connection)}
-        request = self._connection.delete('posts/{0}'.format(self.id),
-                                    data=data,
-                                    headers={'accept': 'application/json'})
+        data = {'authenticity_token': self._connection.get_token()}
+
+        request = self._connection.delete('posts/{0}/likes/{1}'
+                                    .format(self.id,
+                                            self.data['interactions']
+                                                     ['likes'][0]['id']),
+                                    data=data)
         if request.status_code != 204:
-            raise errors.PostError('{0}: Post could not be deleted'.format(request.status_code))
+            raise errors.PostError('{0}: Like could not be removed.'
+                            .format(request.status_code))
 
     def author(self, key='name'):
         """Returns author of the post.
diff --git a/logger.py b/logger.py
new file mode 100644 (file)
index 0000000..b7b700c
--- /dev/null
+++ b/logger.py
@@ -0,0 +1,18 @@
+#!/usr/bin/env python3
+
+"""Module used for obtaining (pod, username, password) tuple.
+
+Used by me when I want to debug in public places and not want to show
+my password.
+"""
+
+import getpass
+
+
+def getdata():
+    """Asks for data.
+    """
+    pod = input('Pod: ')
+    username = input('Username at \'{0}\': '.format(pod))
+    password = getpass.getpass('Password for {0}@{1}: '.format(username, pod))
+    return (pod, username, password)