Example #1
0
    def to_esi_representation(self, value, envelope='data'):
        href = value.get_absolute_url()

        if href:
            esi_url = extend_querystring_params(href, dict(envelope=[envelope, ], format=['jsonapi', ]))
            return '<esi:include src="{}"/>'.format(esi_url)
        return self.to_representation(value)
Example #2
0
    def to_esi_representation(self, value, envelope='data'):
        href = value.get_absolute_url()

        if href:
            esi_url = extend_querystring_params(href, dict(envelope=[envelope, ], format=['jsonapi', ]))
            return '<esi:include src="{}"/>'.format(esi_url)
        return self.to_representation(value)
Example #3
0
 def to_esi_representation(self, value, envelope='data'):
     relationships = super(RelationshipField, self).to_representation(value)
     if relationships is not None and 'related' in relationships.keys():
         href = relationships['related']
         if href and not href == '{}':
             if self.always_embed:
                 envelope = 'data'
             esi_url = extend_querystring_params(href, dict(format=['jsonapi', ], envelope=[envelope, ]))
             return '<esi:include src="{}"/>'.format(esi_url)
     else:
         raise SkipField
Example #4
0
 def to_esi_representation(self, value, envelope='data'):
     relationships = self.to_representation(value)
     try:
         href = relationships['links']['related']['href']
     except KeyError:
         raise SkipField
     else:
         if href and not href == '{}':
             if self.always_embed:
                 envelope = 'data'
             query_dict = dict(format=['jsonapi', ], envelope=[envelope, ])
             if 'view_only' in self.parent.context['request'].query_params.keys():
                 query_dict.update(view_only=[self.parent.context['request'].query_params['view_only']])
             esi_url = extend_querystring_params(href, query_dict)
             return '<esi:include src="{}"/>'.format(esi_url)
Example #5
0
 def to_esi_representation(self, value, envelope='data'):
     relationships = self.to_representation(value)
     try:
         href = relationships['links']['related']['href']
     except KeyError:
         raise SkipField
     else:
         if href and not href == '{}':
             if self.always_embed:
                 envelope = 'data'
             query_dict = dict(format=['jsonapi', ], envelope=[envelope, ])
             if 'view_only' in self.parent.context['request'].query_params.keys():
                 query_dict.update(view_only=[self.parent.context['request'].query_params['view_only']])
             esi_url = extend_querystring_params(href, query_dict)
             return '<esi:include src="{}"/>'.format(esi_url)
Example #6
0
 def to_esi_representation(self, value, envelope='data'):
     relationships = super(RelationshipField, self).to_representation(value)
     if relationships is not None and 'related' in relationships.keys():
         href = relationships['related']
         if href and not href == '{}':
             if self.always_embed:
                 envelope = 'data'
             esi_url = extend_querystring_params(
                 href, dict(format=[
                     'jsonapi',
                 ], envelope=[
                     envelope,
                 ]))
             return '<esi:include src="{}"/>'.format(esi_url)
     else:
         raise SkipField