예제 #1
0
    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
        )
예제 #2
0
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))
예제 #3
0
파일: routes.py 프로젝트: WenTingZhu/osf.io
    '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,
        ),
    ],
}
예제 #4
0
파일: routes.py 프로젝트: WenTingZhu/osf.io
                '/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')),
    ],
}
예제 #5
0
        ], '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'),
예제 #6
0
        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([
예제 #7
0
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/',
예제 #8
0
            [
                '/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'
}
예제 #9
0
        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'
}
예제 #10
0
파일: routes.py 프로젝트: WenTingZhu/osf.io
    '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')),
    ],
}
예제 #11
0
파일: routes.py 프로젝트: scooley/osf.io
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/',
예제 #12
0
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(
예제 #13
0
            '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,
        ),
    ],
}
예제 #14
0
                '/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',
}
예제 #15
0
파일: routes.py 프로젝트: dplorimer/osf
            '/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([
예제 #16
0
        ], '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'))),
예제 #17
0
    ],
    '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>/',
예제 #18
0
파일: routes.py 프로젝트: Doris1989/osf.io
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(
            [
예제 #19
0
        ], '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'))),
예제 #20
0
            [
                '/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',
}
예제 #21
0
파일: routes.py 프로젝트: WenTingZhu/osf.io
            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,
        ),
    ]
}