How to use the ckan.plugins.toolkit.render function in ckan

To help you get started, we’ve selected a few ckan examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ckan / ckanext-pages / ckanext / pages / controller.py View on Github external
error_summary = e.error_summary
                return self.group_edit(id, '/' + page, data,
                                 errors, error_summary)
            p.toolkit.redirect_to('group_pages', id=id, page='/' + _page['name'])

        if not data:
            data = _page

        errors = errors or {}
        error_summary = error_summary or {}

        vars = {'data': data, 'errors': errors,
                'error_summary': error_summary, 'page': page,
                'group_type': 'group'}

        return p.toolkit.render('ckanext_pages/group_page_edit.html',
                               extra_vars=vars)
github ckan / ckanext-issues / ckanext / issues / controller / controller.py View on Github external
def show(self, issue_number, dataset_id):
        dataset = self._before_dataset(dataset_id)
        try:
            extra_vars = show.show(issue_number,
                                   dataset_id,
                                   session=model.Session)
        except toolkit.ValidationError, e:
            p.toolkit.abort(
                404, toolkit._('Issue not found: {0}'.format(e.error_summary)))
        except toolkit.ObjectNotFound, e:
            p.toolkit.abort(
                404, toolkit._('Issue not found: {0}'.format(e)))
        extra_vars['dataset'] = dataset
        return p.toolkit.render('issues/show.html', extra_vars=extra_vars)
github NaturalHistoryMuseum / ckanext-nhm / ckanext / nhm / routes / statistics.py View on Github external
def records():
    '''Render the records stats page.'''

    toolkit.c.datastore_stats = toolkit.get_action(u'dataset_statistics')(
        _context(), {})

    toolkit.c.num_records = get_record_stats()

    return toolkit.render(u'stats/records.html', {
        u'title': u'Record statistics'
        })
github NaturalHistoryMuseum / ckanext-nhm / ckanext / nhm / controllers / page.py View on Github external
def about_credits(self):
        return p.toolkit.render('about/credits.html', {'title': 'Credits'})
github NaturalHistoryMuseum / ckanext-nhm / ckanext / nhm / controllers / page.py View on Github external
c.package_revisions_by_week = rev_stats.get_by_week('package_revisions')
        c.new_packages_by_week = rev_stats.get_by_week('new_packages')

        c.raw_packages_by_week = []
        for week_date, num_packages, cumulative_num_packages in c.num_packages_by_week:
            c.raw_packages_by_week.append({'date': h.date_str_to_datetime(week_date), 'total_packages': cumulative_num_packages})

        c.raw_all_package_revisions = []
        for week_date, revs, num_revisions, cumulative_num_revisions in c.package_revisions_by_week:
            c.raw_all_package_revisions.append({'date': h.date_str_to_datetime(week_date), 'total_revisions': num_revisions})

        c.raw_new_datasets = []
        for week_date, pkgs, num_packages, cumulative_num_packages in c.new_packages_by_week:
            c.raw_new_datasets.append({'date': h.date_str_to_datetime(week_date), 'new_packages': num_packages})

        return p.toolkit.render('about/statistics.html', {'title': 'Statistics'})
github NaturalHistoryMuseum / ckanext-nhm / ckanext / nhm / controllers / dwc.py View on Github external
"""
        View an individual record
        :param id:
        :param resource_id:
        :param record_id:
        :return: html
        """

        self._load_data(package_name, resource_id, record_id)

        c.dwc = DwC(**c.record_dict)

        if c.resource['format'].lower() != 'dwc':
            abort(404, _('Record not in Darwin Core format'))

        return p.toolkit.render('dwc/view.html')
github ckan / ckanext-qa / ckanext / qa / helpers.py View on Github external
def qa_openness_stars_dataset_html(dataset):
    qa = dataset.get('qa')
    if not qa:
        return tk.literal('')
    if not isinstance(qa, dict):
        return tk.literal('')
    extra_vars = copy.deepcopy(qa)
    return tk.literal(
        tk.render('qa/openness_stars_brief.html',
                  extra_vars=extra_vars))
github NaturalHistoryMuseum / ckanext-nhm / ckanext / nhm / routes / help.py View on Github external
def search():
    '''Render the help page for integrated search.'''
    return toolkit.render(u'help/search.html', {
        u'title': u'Integrated Search Help'
        })
github NaturalHistoryMuseum / ckanext-nhm / ckanext / nhm / controllers / legal.py View on Github external
def privacy(self):
        '''Render the privacy notice page.'''
        return toolkit.render(u'legal/privacy.html', {u'title': u'Privacy notice'})
github NaturalHistoryMuseum / ckanext-nhm / ckanext / nhm / controllers / keemu_record.py View on Github external
def view(self, package_name, resource_id, record_id):

        """
        View an individual record
        :param id:
        :param resource_id:
        :param record_id:
        :return: html
        """
        # Try and get the record
        c.record_dict = self._get_record(package_name, resource_id, record_id)
        return p.toolkit.render('record/view.html')