Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed non-boolean User.is_unsubscribed return value

Also changed other mixin methods to return the deserialized json response
  • Loading branch information...
commit 9f31a662cca5c02026af62ff75ee927a195468d8 1 parent fbf728c
@RyanBalfanz authored
Showing with 8 additions and 4 deletions.
  1. +8 −4 sendgrid/mixins.py
View
12 sendgrid/mixins.py
@@ -1,4 +1,5 @@
from django.conf import settings
+from django.utils import simplejson
from utils import add_unsubscribes
from utils import delete_unsubscribes
@@ -17,19 +18,22 @@ def is_unsubscribed(self):
"""
Returns True if the ``User``.``email`` belongs to the unsubscribe list.
"""
- result = get_unsubscribes(email=self.email)
- return result
+ response = get_unsubscribes(email=self.email)
+ results = simplejson.loads(response)
+ return len(results) > 0
def add_to_unsubscribes(self):
"""
Adds the ``User``.``email`` from the unsubscribe list.
"""
- result = add_unsubscribes(email=self.email)
+ response = add_unsubscribes(email=self.email)
+ result = simplejson.loads(response)
return result
def delete_from_unsubscribes(self):
"""
Removes the ``User``.``email`` from the unsubscribe list.
"""
- result = delete_unsubscribes(email=self.email)
+ response = delete_unsubscribes(email=self.email)
+ result = simplejson.loads(response)
return result
Please sign in to comment.
Something went wrong with that request. Please try again.