Пример #1
0
 def get_story_json(self, obj=None):
     if obj is None:
         obj = self.object
     resource = StoryResource()
     bundle = resource.build_bundle(obj=obj)
     to_be_serialized = resource.full_dehydrate(bundle)
     return resource.serialize(None, to_be_serialized, 'application/json')
Пример #2
0
 def get_context_data(self, **kwargs):
     resource = StoryResource()
     to_be_serialized = resource.explore_get_data_to_be_serialized(self.request)
     return {
         'stories_json': mark_safe(resource.serialize(None, to_be_serialized,
                                                      'application/json')),
         'selected_filters': mark_safe(json.dumps(self._get_selected_filters())),
         'view_type': mark_safe(json.dumps(self._get_selected_view_type()))
     }
Пример #3
0
 def get_context_data(self, **kwargs):
     resource = StoryResource()
     to_be_serialized = resource.explore_get_data_to_be_serialized(
         self.request)
     return {
         'stories_json':
         mark_safe(
             resource.serialize(None, to_be_serialized,
                                'application/json')),
         'selected_filters':
         mark_safe(json.dumps(self._get_selected_filters())),
         'view_type':
         mark_safe(json.dumps(self._get_selected_view_type()))
     }
Пример #4
0
 def get_story_json(self):
     resource = StoryResource()
     bundle = resource.build_bundle(obj=self.object)
     to_be_serialized = resource.full_dehydrate(bundle)
     return resource.serialize(None, to_be_serialized, 'application/json')