from rest_framework import serializers

from .models import Notification


class NotificationSerializer(serializers.ModelSerializer):
    target = serializers.Field(source='data.target')
    action_object = serializers.Field(source='data.action_object')
    actor = serializers.Field(source='data.sender')
    timesince = serializers.Field(source='timesince')

    class Meta:
        model = Notification
        fields = ('target', 'action_object', 'actor', 'verb', 'timesince',
                  'date_created', 'date_modified')

@@ -1,12 +1,61 @@
+from django.utils.six.moves.urllib import parse%0A%0A
 from rest_fr
@@ -82,16 +82,54 @@
 lizers%0A%0A
+from ..files.utils import sign_s3_url%0A
 from .mo
@@ -243,33 +243,46 @@
 ers.
-Field(source='data.
+SerializerMethodField('get_
 target
+_data
 ')%0A 
@@ -312,35 +312,43 @@
 alizers.
-Field(source='data.
+SerializerMethodField('get_
 action_o
@@ -352,16 +352,21 @@
 n_object
+_data
 ')%0A    a
@@ -638,8 +638,748 @@
 ified')%0A
+%0A    def get_action_object_data(self, obj):%0A        return self._data_with_signed_urls(obj.data%5B'action_object'%5D)%0A%0A    def get_target_data(self, obj):%0A        return self._data_with_signed_urls(obj.data%5B'target'%5D)%0A%0A    def _data_with_signed_urls(self, data):%0A        thumbnail_keys = %5B%0A            'thumbnail_sm_path',%0A            'thumbnail_md_path',%0A            'thumbnail_lg_path'%0A        %5D%0A%0A        for key, value in data.items():%0A            if key in thumbnail_keys and value:%0A                split_results = list(tuple(parse.urlsplit(value)))%0A                split_results%5B-2%5D = ''%0A                cleaned_url = parse.unquote(parse.urlunsplit(split_results))%0A                data%5Bkey%5D = sign_s3_url(cleaned_url)%0A%0A        return data%0A

Fix action object and target thumbnail urls