def setUp(self): super(WebRendererTestCase, self).setUp() # Use OsfRenderer so that global vars are included self.r = OsfWebRenderer( os.path.join(TEMPLATES_PATH, 'main.html'), render_mako_string )
def handle_error(code): """Display an error thrown outside a routed view function. :param int code: Error status code :return: Flask `Response` object """ # TODO: Remove circular import from website.routes import OsfWebRenderer json_renderer = JSONRenderer() web_renderer = OsfWebRenderer('', render_mako_string) error = HTTPError(code) renderer = json_renderer if is_json_request() else web_renderer return make_response(renderer.handle_error(error))
'prefix': '/api/v1' } web_routes = { 'rules': [ ##### View file ##### Rule( [ '/project/<pid>/dropbox/files/<path:path>', '/project/<pid>/node/<nid>/dropbox/files/<path:path>', ], 'get', views.crud.dropbox_view_file, OsfWebRenderer( '../addons/dropbox/templates/dropbox_view_file.mako'), ), ##### Download file ##### Rule( [ '/project/<pid>/dropbox/files/<path:path>/download/', '/project/<pid>/node/<nid>/dropbox/files/<path:path>/download/', ], 'get', views.crud.dropbox_download, notemplate, ), ], }
'/project/<pid>/node/<nid>/figshare/render/article/<aid>/file/<fid>/' ], 'get', views.crud.figshare_get_rendered_file, json_renderer, ), Rule( [ '/project/<pid>/figshare/download/article/<aid>/file/<fid>/', '/project/<pid>/node/<nid>/figshare/download/article/<aid>/file/<fid>/' ], 'get', views.crud.figshare_download_file, json_renderer, ), ], 'prefix': '/api/v1', } page_routes = { 'rules': [ Rule([ '/project/<pid>/figshare/article/<aid>/file/<fid>/', '/project/<pid>/node/<nid>/figshare/article/<aid>/file/<fid>/', ], 'get', views.crud.figshare_view_file, OsfWebRenderer( '../addons/figshare/templates/figshare_view_file.mako')), ], }
], 'get', views.wiki_widget, json_renderer), ], 'prefix': '/api/v1', } # NOTE: <wname> refers to a wiki page's key, e.g. 'Home' page_routes = { 'rules': [ # Home (Base) | GET Rule([ '/project/<pid>/wiki/', '/project/<pid>/node/<nid>/wiki/', ], 'get', views.project_wiki_home, OsfWebRenderer(os.path.join(TEMPLATE_DIR, 'edit.mako'), trust=False)), # View (Id) | GET Rule([ '/project/<pid>/wiki/id/<wid>/', '/project/<pid>/node/<nid>/wiki/id/<wid>/', ], 'get', views.project_wiki_id_page, OsfWebRenderer(os.path.join(TEMPLATE_DIR, 'edit.mako'), trust=False)), # Wiki | GET Rule([ '/project/<pid>/wiki/<wname>/', '/project/<pid>/node/<nid>/wiki/<wname>/', ], 'get', views.project_wiki_view, OsfWebRenderer(os.path.join(TEMPLATE_DIR, 'edit.mako'),
Rule([ '/project/<pid>/dataverse/file/<path:path>/', '/project/<pid>/node/<nid>/dataverse/file/<path:path>/', ], 'delete', views.crud.dataverse_delete_file, json_renderer), ], 'prefix': '/api/v1', } page_routes = { 'rules': [ Rule([ '/project/<pid>/dataverse/file/<path:path>/', '/project/<pid>/node/<nid>/dataverse/file/<path:path>/', ], 'get', views.crud.dataverse_view_file, OsfWebRenderer( '../addons/dataverse/templates/dataverse_view_file.mako')), Rule( [ '/project/<pid>/dataverse/file/<path:path>/download/', '/project/<pid>/node/<nid>/dataverse/file/<path:path>/download/', ], 'get', views.crud.dataverse_download_file, notemplate, ), ], } api_routes = { 'rules': [ Rule([
from website.routes import OsfWebRenderer from framework.routing import Rule, json_renderer from . import views render_routes = { 'rules': [ Rule([ '/project/<pid>/badges/', '/project/<pid>/node/<nid>/badges/', ], 'get', views.render.badges_page, OsfWebRenderer('../addons/badges/templates/badges_page.mako')), ], } api_urls = { 'rules': [ Rule('/badges/new/', 'post', views.crud.create_badge, json_renderer), Rule('/dashboard/get_badges/', 'get', views.render.dashboard_badges, json_renderer), Rule('/dashboard/get_assertions/', 'get', views.render.dashboard_assertions, json_renderer), Rule('/profile/<uid>/badges/json/', 'get', views.render.organization_badges_listing, json_renderer), Rule([ '/project/<pid>/badges/award/', '/project/<pid>/node/<nid>/badges/award/', ], 'post', views.crud.award_badge, json_renderer), Rule([ '/project/<pid>/badges/revoke/', '/project/<pid>/node/<nid>/badges/revoke/',
[ '/project/<pid>/dataverse/publish/', '/project/<pid>/node/<nid>/dataverse/publish/', ], 'put', views.crud.dataverse_publish_dataset, json_renderer, ), Rule( [ '/project/<pid>/dataverse/widget/', '/project/<pid>/node/<nid>/dataverse/widget/', ], 'get', views.widget.dataverse_widget, OsfWebRenderer( '../addons/dataverse/templates/dataverse_widget.mako'), ), Rule( [ '/project/<pid>/dataverse/widget/contents/', '/project/<pid>/node/<nid>/dataverse/widget/contents/', ], 'get', views.widget.dataverse_get_widget_contents, json_renderer, ), ], 'prefix': '/api/v1' }
Rule( [ '/project/<pid>/dataverse/publish/', '/project/<pid>/node/<nid>/dataverse/publish/', ], 'put', views.dataverse_publish_dataset, json_renderer, ), Rule( [ '/project/<pid>/dataverse/widget/', '/project/<pid>/node/<nid>/dataverse/widget/', ], 'get', views.dataverse_widget, OsfWebRenderer('../addons/dataverse/templates/dataverse_widget.mako', trust=False), ), Rule( [ '/project/<pid>/dataverse/widget/contents/', '/project/<pid>/node/<nid>/dataverse/widget/contents/', ], 'get', views.dataverse_get_widget_contents, json_renderer, ), ], 'prefix': '/api/v1' }
'rules': [ Rule([ '/project/<pid>/zotero/widget/', '/project/<pid>/node/<nid>/zotero/widget/', ], 'get', views.zotero_widget, json_renderer), ], 'prefix': '/api/v1', } settings_routes = { 'rules': [ Rule([ '/project/<pid>/zotero/settings/', '/project/<pid>/node/<nid>/zotero/settings/', ], 'post', views.zotero_set_config, json_renderer), ], 'prefix': '/api/v1', } page_routes = { 'rules': [ Rule([ '/project/<pid>/zotero/', '/project/<pid>/node/<nid>/zotero/', ], 'get', views.zotero_page, OsfWebRenderer('../addons/zotero/templates/zotero_page.mako')), ], }
from website.routes import OsfWebRenderer from framework.routing import Rule, json_renderer from . import views render_routes = { 'rules': [ Rule([ '/project/<pid>/badges/', '/project/<pid>/node/<nid>/badges/', ], 'get', views.render.badges_page, OsfWebRenderer('../addons/badges/templates/badges_page.mako', trust=False)), ], } api_urls = { 'rules': [ Rule('/badges/new/', 'post', views.crud.create_badge, json_renderer), Rule('/dashboard/get_badges/', 'get', views.render.dashboard_badges, json_renderer), Rule('/dashboard/get_assertions/', 'get', views.render.dashboard_assertions, json_renderer), Rule('/profile/<uid>/badges/json/', 'get', views.render.organization_badges_listing, json_renderer), Rule([ '/project/<pid>/badges/award/', '/project/<pid>/node/<nid>/badges/award/', ], 'post', views.crud.award_badge, json_renderer), Rule([ '/project/<pid>/badges/revoke/',
from . import views oauth_routes = { 'rules': [ Rule( '/connect/weko/<repoid>/', 'get', views.weko_oauth_connect, json_renderer, ), Rule( '/callback/weko/<repoid>/', 'get', views.weko_oauth_callback, OsfWebRenderer('util/oauth_complete.mako', trust=False), ), ], 'prefix': '/oauth' } api_routes = { 'rules': [ Rule( '/settings/weko/', 'get', views.weko_user_config_get, json_renderer, ), Rule(
'get', views.crud.github_get_rendered_file, json_renderer, ), ], 'prefix': '/api/v1' } page_routes = { 'rules': [ Rule( [ '/project/<pid>/github/file/<path:path>/', '/project/<pid>/node/<nid>/github/file/<path:path>/', ], 'get', views.crud.github_view_file, OsfWebRenderer('../addons/github/templates/github_view_file.mako'), ), Rule( [ '/project/<pid>/github/file/<path:path>/download/', '/project/<pid>/node/<nid>/github/file/<path:path>/download/', ], 'get', views.crud.github_download_file, notemplate, ), ], }
'/project/<pid>/forward/config/', '/project/<pid>/node/<nid>/forward/config/' ], 'get', views.config.forward_config_get, json_renderer, ), Rule( [ '/project/<pid>/forward/config/', '/project/<pid>/node/<nid>/forward/config/' ], 'put', views.config.forward_config_put, json_renderer, ), Rule( [ '/project/<pid>/forward/widget/', '/project/<pid>/node/<nid>/forward/widget/', ], 'get', views.widget.forward_widget, OsfWebRenderer('../addons/forward/templates/forward_widget.mako', trust=False), ) ], 'prefix': '/api/v1', }
'/project/<pid>/node/<nid>/wiki/widget/', ], 'get', views.wiki_widget, json_renderer), ], 'prefix': '/api/v1', } # NOTE: <wname> refers to a wiki page's key, e.g. 'Home' page_routes = { 'rules': [ # Home (Base) | GET Rule([ '/project/<pid>/wiki/', '/project/<pid>/node/<nid>/wiki/', ], 'get', views.project_wiki_home, OsfWebRenderer(os.path.join(TEMPLATE_DIR, 'edit.mako'))), # View (Id) | GET Rule([ '/project/<pid>/wiki/id/<wid>/', '/project/<pid>/node/<nid>/wiki/id/<wid>/', ], 'get', views.project_wiki_id_page, OsfWebRenderer(os.path.join(TEMPLATE_DIR, 'edit.mako'))), # Wiki | GET Rule([ '/project/<pid>/wiki/<wname>/', '/project/<pid>/node/<nid>/wiki/<wname>/', ], 'get', views.project_wiki_view, OsfWebRenderer(os.path.join(TEMPLATE_DIR, 'edit.mako'))), # Edit | GET (legacy url, trigger redirect) Rule([
], 'get', views.wiki_widget, json_renderer), ], 'prefix': '/api/v1', } # NOTE: <wname> refers to a wiki page's key, e.g. 'Home' page_routes = { 'rules': [ # Home (Base) | GET Rule([ '/project/<pid>/wiki/', '/project/<pid>/node/<nid>/wiki/', ], 'get', views.project_wiki_home, OsfWebRenderer(os.path.join(TEMPLATE_DIR, 'wiki.mako'))), # View (Id) | GET Rule([ '/project/<pid>/wiki/id/<wid>/', '/project/<pid>/node/<nid>/wiki/id/<wid>/', ], 'get', views.project_wiki_id_page, OsfWebRenderer(os.path.join(TEMPLATE_DIR, 'wiki.mako'))), # View (Name) | GET Rule([ '/project/<pid>/wiki/<wname>/', '/project/<pid>/node/<nid>/wiki/<wname>/', ], 'get', views.project_wiki_page, OsfWebRenderer(os.path.join(TEMPLATE_DIR, 'wiki.mako'))),
], 'prefix': '/api/v1', } # NOTE: <wname> refers to a wiki page's key, e.g. 'Home' page_routes = { 'rules': [ # Home (Base) | GET Rule([ '/project/<pid>/wiki/', '/project/<pid>/node/<nid>/wiki/', ], 'get', views.project_wiki_home, OsfWebRenderer('edit.mako', trust=False, template_dir=TEMPLATE_DIR)), # View (Id) | GET Rule([ '/project/<pid>/wiki/id/<wid>/', '/project/<pid>/node/<nid>/wiki/id/<wid>/', ], 'get', views.project_wiki_id_page, OsfWebRenderer('edit.mako', trust=False, template_dir=TEMPLATE_DIR)), # Wiki | GET Rule([ '/project/<pid>/wiki/<wname>/', '/project/<pid>/node/<nid>/wiki/<wname>/',
from website.routes import OsfWebRenderer, notemplate from website.addons.osfstorage import views web_routes = { 'rules': [ Rule( [ '/project/<pid>/osfstorage/files/<path:path>/', '/project/<pid>/node/<nid>/osfstorage/files/<path:path>/', ], 'get', views.osf_storage_view_file, OsfWebRenderer('../addons/osfstorage/templates/osfstorage_view_file.mako'), ), Rule( [ # Legacy routes for `view_file` '/project/<pid>/osffiles/<fid>/', '/project/<pid>/node/<nid>/osffiles/<fid>/', ], 'get', views.osf_storage_view_file_legacy, OsfWebRenderer('../addons/osfstorage/templates/osfstorage_view_file.mako'), ), Rule( [
], 'get', views.wiki_widget, json_renderer), ], 'prefix': '/api/v1', } # NOTE: <wname> refers to a wiki page's key, e.g. 'Home' page_routes = { 'rules': [ # Home (Base) | GET Rule([ '/project/<pid>/wiki/', '/project/<pid>/node/<nid>/wiki/', ], 'get', views.project_wiki_home, OsfWebRenderer(os.path.join(TEMPLATE_DIR, 'edit.mako'))), # View (Id) | GET Rule([ '/project/<pid>/wiki/id/<wid>/', '/project/<pid>/node/<nid>/wiki/id/<wid>/', ], 'get', views.project_wiki_id_page, OsfWebRenderer(os.path.join(TEMPLATE_DIR, 'edit.mako'))), # Wiki | GET Rule([ '/project/<pid>/wiki/<wname>/', '/project/<pid>/node/<nid>/wiki/<wname>/', ], 'get', views.project_wiki_view, OsfWebRenderer(os.path.join(TEMPLATE_DIR, 'edit.mako'))),
[ '/project/<pid>/forward/config/', '/project/<pid>/node/<nid>/forward/config/' ], 'get', views.config.forward_config_get, json_renderer, ), Rule( [ '/project/<pid>/forward/config/', '/project/<pid>/node/<nid>/forward/config/' ], 'put', views.config.forward_config_put, json_renderer, ), Rule( [ '/project/<pid>/forward/widget/', '/project/<pid>/node/<nid>/forward/widget/', ], 'get', views.widget.forward_widget, OsfWebRenderer('../addons/forward/templates/forward_widget.mako'), ) ], 'prefix': '/api/v1', }
views.crud.file_delete_info, json_renderer, ), ], 'prefix': '/api/v1', } nonapi_routes = { 'rules': [ Rule( [ '/project/<pid>/s3/<path:path>/', '/project/<pid>/node/<nid>/s3/<path:path>/' ], 'get', views.crud.s3_view, OsfWebRenderer('../addons/s3/templates/s3_view_file.mako'), ), Rule( [ '/project/<pid>/s3/<path:path>/download/', '/project/<pid>/node/<nid>/s3/<path:path>/download/' ], 'get', views.crud.s3_download, json_renderer, ), ] }