mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Adding handler to to_json calls on all serialized models.
This commit is contained in:
parent
6e1ebce64a
commit
bd87f3484b
2 changed files with 10 additions and 1 deletions
|
@ -1265,6 +1265,13 @@ class DuplicateFeed(models.Model):
|
|||
|
||||
def __unicode__(self):
|
||||
return "%s: %s" % (self.feed, self.duplicate_address)
|
||||
|
||||
def to_json(self):
|
||||
return {
|
||||
'duplicate_address': self.duplicate_address,
|
||||
'duplicate_feed_id': self.duplicate_feed_id,
|
||||
'feed_id': self.feed.pk
|
||||
}
|
||||
|
||||
def merge_feeds(original_feed_id, duplicate_feed_id, force=False):
|
||||
from apps.reader.models import UserSubscription
|
||||
|
|
|
@ -43,7 +43,9 @@ def json_encode(data, *args, **kwargs):
|
|||
# Opps, we used to check if it is of type list, but that fails
|
||||
# i.e. in the case of django.newforms.utils.ErrorList, which extends
|
||||
# the type "list". Oh man, that was a dumb mistake!
|
||||
if isinstance(data, list):
|
||||
if hasattr(data, 'to_json'):
|
||||
ret = data.to_json()
|
||||
elif isinstance(data, list):
|
||||
ret = _list(data)
|
||||
# Same as for lists above.
|
||||
elif isinstance(data, dict):
|
||||
|
|
Loading…
Add table
Reference in a new issue