Esempio n. 1
0
 def test_organization_navigation_legacy_routes(self):
     org_name = "test-org"
     assert (h.build_nav_icon("organization_read", "Datasets", id=org_name)
             == '<li><a href="/organization/test-org">Datasets</a></li>')
     assert (
         h.build_nav_icon("organization_activity",
                          "Activity Stream",
                          id=org_name) ==
         '<li><a href="/organization/activity/test-org">Activity Stream</a></li>'
     )
     assert (h.build_nav_icon("organization_about", "About", id=org_name) ==
             '<li><a href="/organization/about/test-org">About</a></li>')
Esempio n. 2
0
 def test_organization_navigation_legacy_routes(self):
     org_name = 'test-org'
     eq_(h.build_nav_icon('organization_read', 'Datasets', id=org_name),
         '<li><a href="/organization/test-org">Datasets</a></li>')
     eq_(
         h.build_nav_icon('organization_activity',
                          'Activity Stream',
                          id=org_name),
         '<li><a href="/organization/activity/test-org">Activity Stream</a></li>'
     )
     eq_(h.build_nav_icon('organization_about', 'About', id=org_name),
         '<li><a href="/organization/about/test-org">About</a></li>')
Esempio n. 3
0
 def test_group_navigation_legacy_routes(self):
     group_name = "test-group"
     assert (h.build_nav_icon("group_read", "Datasets", id=group_name) ==
             '<li><a href="/group/test-group">Datasets</a></li>')
     assert (
         h.build_nav_icon("group_activity",
                          "Activity Stream",
                          id=group_name) ==
         '<li><a href="/group/activity/test-group">Activity Stream</a></li>'
     )
     assert (h.build_nav_icon("group_about", "About", id=group_name) ==
             '<li><a href="/group/about/test-group">About</a></li>')
Esempio n. 4
0
 def test_dataset_navigation_legacy_routes(self):
     dataset_name = 'test-dataset'
     eq_(h.build_nav_icon('dataset_read', 'Datasets', id=dataset_name),
         '<li><a href="/dataset/test-dataset">Datasets</a></li>')
     eq_(h.build_nav_icon('dataset_groups', 'Groups', id=dataset_name),
         '<li><a href="/dataset/groups/test-dataset">Groups</a></li>')
     eq_(
         h.build_nav_icon('dataset_activity',
                          'Activity Stream',
                          id=dataset_name),
         '<li><a href="/dataset/activity/test-dataset">Activity Stream</a></li>'
     )
Esempio n. 5
0
 def test_group_navigation_legacy_routes(self):
     group_name = 'test-group'
     eq_(h.build_nav_icon('group_read', 'Datasets', id=group_name),
         '<li><a href="/group/test-group">Datasets</a></li>')
     eq_(
         h.build_nav_icon('group_activity',
                          'Activity Stream',
                          id=group_name),
         '<li><a href="/group/activity/test-group">Activity Stream</a></li>'
     )
     eq_(h.build_nav_icon('group_about', 'About', id=group_name),
         '<li><a href="/group/about/test-group">About</a></li>')
Esempio n. 6
0
 def test_dataset_navigation_legacy_routes(self):
     dataset_name = "test-dataset"
     assert (h.build_nav_icon("dataset_read", "Datasets", id=dataset_name)
             == '<li><a href="/dataset/test-dataset">Datasets</a></li>')
     assert (h.build_nav_icon("dataset_groups", "Groups",
                              id=dataset_name) ==
             '<li><a href="/dataset/groups/test-dataset">Groups</a></li>')
     assert (
         h.build_nav_icon("dataset_activity",
                          "Activity Stream",
                          id=dataset_name) ==
         '<li><a href="/dataset/activity/test-dataset">Activity Stream</a></li>'
     )
Esempio n. 7
0
 def test_organization_navigation_legacy_routes(self):
     org_name = 'test-org'
     eq_(
         h.build_nav_icon('organization_read', 'Datasets', id=org_name),
         '<li><a href="/organization/test-org">Datasets</a></li>'
     )
     eq_(
         h.build_nav_icon('organization_activity', 'Activity Stream', id=org_name),
         '<li><a href="/organization/activity/test-org">Activity Stream</a></li>'
     )
     eq_(
         h.build_nav_icon('organization_about', 'About', id=org_name),
         '<li><a href="/organization/about/test-org">About</a></li>'
     )
Esempio n. 8
0
 def test_group_navigation_legacy_routes(self):
     group_name = 'test-group'
     eq_(
         h.build_nav_icon('group_read', 'Datasets', id=group_name),
         '<li><a href="/group/test-group">Datasets</a></li>'
     )
     eq_(
         h.build_nav_icon('group_activity', 'Activity Stream', id=group_name),
         '<li><a href="/group/activity/test-group">Activity Stream</a></li>'
     )
     eq_(
         h.build_nav_icon('group_about', 'About', id=group_name),
         '<li><a href="/group/about/test-group">About</a></li>'
     )
Esempio n. 9
0
 def test_dataset_navigation_legacy_routes(self):
     dataset_name = 'test-dataset'
     eq_(
         h.build_nav_icon('dataset_read', 'Datasets', id=dataset_name),
         '<li><a href="/dataset/test-dataset">Datasets</a></li>'
     )
     eq_(
         h.build_nav_icon('dataset_groups', 'Groups', id=dataset_name),
         '<li><a href="/dataset/groups/test-dataset">Groups</a></li>'
     )
     eq_(
         h.build_nav_icon('dataset_activity', 'Activity Stream', id=dataset_name),
         '<li><a href="/dataset/activity/test-dataset">Activity Stream</a></li>'
     )
Esempio n. 10
0
def build_specimen_nav_items(package_name, resource_id, record_id, version=None):
    '''
    Creates the specimen nav items allowing the user to navigate to different views of the specimen
    record data. A list of nav items is returned.

    :param package_name: the package name (or id)
    :param resource_id: the resource id
    :param record_id: the record id
    :param version: the version of the record, or None if no version is present
    :return: a list of nav items
    '''
    link_definitions = [
        (u'record', _(u'Normal view')),
        (u'dwc', _(u'Darwin Core view')),
    ]
    links = []
    for route_name, link_text in link_definitions:
        kwargs = {
            u'package_name': package_name,
            u'resource_id': resource_id,
            u'record_id': record_id,
        }
        # if there's a version, alter the target of our nav item (the name of the route) and add the
        # version to kwargs we're going to pass to the nav builder helper function
        if version is not None:
            route_name = u'{}_versioned'.format(route_name)
            kwargs[u'version'] = version
        # build the nav and add it to the list
        links.append(build_nav_icon(route_name, link_text, **kwargs))

    return links
Esempio n. 11
0
def hdx_build_nav_icon_with_message(menu_item, title, **kw):
    htmlResult = h.build_nav_icon(menu_item, title, **kw)
    if 'message' not in kw or not kw['message']:
        return htmlResult
    else:
        newResult = str(htmlResult).replace('</a>',
                                            ' <span class="nav-short-message">{message}</span></a>'.format(message=kw['message']))
        return h.literal(newResult)
Esempio n. 12
0
def hdx_build_nav_icon_with_message(menu_item, title, **kw):
    htmlResult = h.build_nav_icon(menu_item, title, **kw)
    if 'message' not in kw or not kw['message']:
        return htmlResult
    else:
        newResult = str(htmlResult).replace('</a>',
                                            ' <span class="nav-short-message">{message}</span></a>'.format(
                                                message=kw['message']))
        return h.literal(newResult)
Esempio n. 13
0
def hdx_build_nav_no_icon(menu_item, title, **kw):
    html_result = str(h.build_nav_icon(menu_item, title, **kw))
    print html_result
    start = html_result.find('<i ') - 1
    end = html_result.find('</i>') + 4
    if start > 0:
        new_result = html_result[0:start] + ' class="no-icon">' + html_result[end:]
    else:
        new_result = html_result
    print new_result
    return h.literal(new_result)
Esempio n. 14
0
 def test_build_nav_icon(self):
     link = h.build_nav_icon('organization.edit',
                             'Edit',
                             id='org-id',
                             icon='pencil-square-o')
     assert link == '<li><a href="/organization/edit/org-id"><i class="fa fa-pencil-square-o"></i> Edit</a></li>'