Пример #1
0
def drill_down_url(alternative_url=None, **by):
    return h.add_url_param(
        alternative_url=alternative_url,
        controller=u'dataset',
        action=u'search',
        new_params=by
    )
Пример #2
0
 def drill_down_url(alternative_url=None, **by):
     return h.add_url_param(
         alternative_url=alternative_url,
         controller='package',
         action='search',
         new_params=by
     )
Пример #3
0
Файл: group.py Проект: ckan/ckan
 def drill_down_url(**by):
     return h.add_url_param(
         alternative_url=None,
         controller=u'group',
         action=u'read',
         extras=dict(id=g.group_dict.get(u'name')),
         new_params=by)
Пример #4
0
 def test_controller_action(self, test_request_context, controller, action,
                            extras):
     with test_request_context(u'/dataset/'):
         assert h.add_url_param(controller=controller,
                                action=action,
                                extras=extras) == h.url_for(
                                    controller + '.' + action, **extras)
Пример #5
0
def drill_down_url(alternative_url=None, **by):
    return h.add_url_param(
        alternative_url=alternative_url,
        controller=u'dataset',
        action=u'search',
        new_params=by
    )
 def drill_down_url(alternative_url=None, **by):
     return h.add_url_param(
         alternative_url=alternative_url,
         controller='package',
         action='search',
         new_params=by
     )
Пример #7
0
 def drill_down_url(alternative_url=None, **by):
     return h.add_url_param(
         alternative_url=alternative_url,
         controller=
         'ckanext.sixodp_showcase.controller:Sixodp_ShowcaseController',
         action='search',
         new_params=by)
Пример #8
0
def drill_down_url(alternative_url: Optional[str] = None, **by: Any) -> str:
    return h.add_url_param(
        alternative_url=alternative_url,
        controller=u'dataset',
        action=u'search',
        new_params=by
    )
Пример #9
0
 def drill_down_url(**by: Any):
     return h.add_url_param(
         alternative_url=None,
         controller=group_type,
         action=u'read',
         extras=dict(id=g.group_dict.get(u'name')),
         new_params=by)
Пример #10
0
 def drill_down_url(**by):
     return h.add_url_param(
         alternative_url=None,
         controller="group",
         action="read",
         extras=dict(id=c.group_dict.get("name")),
         new_params=by,
     )
Пример #11
0
def read(group_type: str,
         is_organization: bool,
         id: Optional[str] = None,
         limit: int = 20) -> Union[str, Response]:
    extra_vars = {}
    set_org(is_organization)
    context = cast(Context, {
        u'model': model,
        u'session': model.Session,
        u'user': g.user,
        u'schema': _db_to_form_schema(group_type=group_type),
        u'for_view': True
    })
    data_dict: dict[str, Any] = {u'id': id, u'type': group_type}

    # unicode format (decoded from utf8)
    q = request.args.get(u'q', u'')

    extra_vars["q"] = q

    try:
        # Do not query for the group datasets when dictizing, as they will
        # be ignored and get requested on the controller anyway
        data_dict['include_datasets'] = False

        # Do not query group members as they aren't used in the view
        data_dict['include_users'] = False

        group_dict = _action(u'group_show')(context, data_dict)
        group = context['group']
    except (NotFound, NotAuthorized):
        base.abort(404, _(u'Group not found'))

    # if the user specified a group id, redirect to the group name
    if data_dict['id'] == group_dict['id'] and \
            data_dict['id'] != group_dict['name']:

        url_with_name = h.url_for(u'{}.read'.format(group_type),
                                  id=group_dict['name'])

        return h.redirect_to(
            h.add_url_param(alternative_url=url_with_name))

    # TODO: Remove
    # ckan 2.9: Adding variables that were removed from c object for
    # compatibility with templates in existing extensions
    g.q = q
    g.group_dict = group_dict
    g.group = group

    extra_vars = _read(id, limit, group_type)

    extra_vars["group_type"] = group_type
    extra_vars["group_dict"] = group_dict

    return base.render(
        _get_group_template(u'read_template', cast(str, g.group_dict['type'])),
        extra_vars)
Пример #12
0
def read(group_type, is_organization, id=None, limit=20):
    extra_vars = {}
    set_org(is_organization)
    context = {
        u'model': model,
        u'session': model.Session,
        u'user': g.user,
        u'schema': _db_to_form_schema(group_type=group_type),
        u'for_view': True
    }
    data_dict = {u'id': id, u'type': group_type}

    # unicode format (decoded from utf8)
    q = request.params.get(u'q', u'')

    extra_vars["q"] = q

    try:
        # Do not query for the group datasets when dictizing, as they will
        # be ignored and get requested on the controller anyway
        data_dict['include_datasets'] = False

        # Do not query group members as they aren't used in the view
        data_dict['include_users'] = False

        group_dict = _action(u'group_show')(context, data_dict)
        group = context['group']
    except (NotFound, NotAuthorized):
        base.abort(404, _(u'Group not found'))

    # if the user specified a group id, redirect to the group name
    if data_dict['id'] == group_dict['id'] and \
            data_dict['id'] != group_dict['name']:

        url_with_name = h.url_for(u'{}.read'.format(group_type),
                                  id=group_dict['name'])

        return h.redirect_to(
            h.add_url_param(alternative_url=url_with_name))

    # TODO: Remove
    # ckan 2.9: Adding variables that were removed from c object for
    # compatibility with templates in existing extensions
    g.q = q
    g.group_dict = group_dict
    g.group = group

    extra_vars = _read(id, limit, group_type)

    extra_vars["group_type"] = group_type
    extra_vars["group_dict"] = group_dict

    return base.render(_read_template(g.group_dict['type']), extra_vars)
Пример #13
0
 def test_alternative_url(self, test_request_context):
     with test_request_context(u'/dataset'):
         assert h.add_url_param(u'/group') == u'/group'
         assert h.add_url_param(u'/group',
                                new_params={'x': 'y'}) == u'/group?x=y'
         assert h.add_url_param() == u'/dataset/'
Пример #14
0
 def drill_down_url(**by):
     return h.add_url_param(alternative_url=None,
                            controller='group',
                            action='read',
                            extras=dict(id=c.group_dict.get('name')),
                            new_params=by)
Пример #15
0
 def drill_down_url(**by):
     return h.add_url_param(alternative_url=None,
                            controller='organization', action='read',
                            extras=dict(id=c.group_dict.get('name')),
                            new_params=by)
Пример #16
0
 def test_new_param(self, test_request_context, url, params, expected):
     with test_request_context(url):
         assert h.add_url_param(new_params=params) == expected
Пример #17
0
 def drill_down_url(alternative_url=None, **by):
     return h.add_url_param(alternative_url=alternative_url,
                            controller='user', action=action,
                            extras=dict(id=c.userobj.id),
                            new_params=by)
Пример #18
0
 def drill_down_url(alternative_url=None, **by):
     return h.add_url_param(alternative_url=alternative_url,
                            controller='dataset'
                            if tk.check_ckan_version('2.9') else 'package',
                            action='search',
                            new_params=by)
Пример #19
0
def drill_down_url(**by):
    return h.add_url_param(alternative_url=None,
                           controller=c.controller,
                           action='read',
                           extras=dict(id=c.id),
                           new_params=by)
Пример #20
0
 def drill_down_url(alternative_url=None, **by):
     return h.add_url_param(alternative_url=alternative_url,
                            controller='user',
                            action=action,
                            extras=dict(id=c.userobj.id),
                            new_params=by)
Пример #21
0
 def drill_down_url(alternative_url=None, **by):
     return h.add_url_param(alternative_url=alternative_url,
                            controller='ckanext.sixodp_showcase.controller:Sixodp_ShowcaseController', action='search',
                            new_params=by)