コード例 #1
0
ファイル: views.py プロジェクト: denverfoundation/storybase
 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
ファイル: views.py プロジェクト: denverfoundation/storybase
 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')
コード例 #5
0
from storybase_help.api import (HelpResource)
from storybase_story.api import StoryResource
from storybase_taxonomy.api import TagResource

# Override default error handler with one that uses RequestContext
handler500 = 'storybase.views.defaults.server_error'

admin.autodiscover()

urlpatterns = patterns('')

# Set up Tastypie API resources
v0_1_api = Api(api_name='0.1')
v0_1_api.register(AssetResource())
v0_1_api.register(DataSetResource())
v0_1_api.register(StoryResource())
v0_1_api.register(GeocoderResource())
v0_1_api.register(GeoLevelResource())
v0_1_api.register(LocationResource())
v0_1_api.register(PlaceResource())
v0_1_api.register(HelpResource())
v0_1_api.register(TagResource())
urlpatterns += patterns('', 
    # REST API
    (r'^api/', include(v0_1_api.urls)),
    # Proxy for Creative Commons endpoint
    # Cache responses for 24 hours
    url(r"^api/%s/license/get/" % v0_1_api.api_name,
        cache_page(60 * 60 * 24)(CreativeCommonsLicenseGetProxyView.as_view()),
        name="api_cc_license_get"),
)