From 15848b236d7fc80ba0134708fc00c161cc76cb5f Mon Sep 17 00:00:00 2001 From: Sergey Motornyuk Date: Wed, 9 Sep 2020 19:04:15 +0300 Subject: [PATCH 001/447] Remove group tags --- ckan/lib/dictization/model_dictize.py | 10 -------- ckan/logic/action/get.py | 16 +------------ .../lib/dictization/test_model_dictize.py | 24 ------------------- 3 files changed, 1 insertion(+), 49 deletions(-) diff --git a/ckan/lib/dictization/model_dictize.py b/ckan/lib/dictization/model_dictize.py index ecaa57652ca..1e4ba1547b0 100644 --- a/ckan/lib/dictization/model_dictize.py +++ b/ckan/lib/dictization/model_dictize.py @@ -32,7 +32,6 @@ def group_list_dictize(obj_list, context, sort_key=lambda x: x['display_name'], reverse=False, with_package_counts=True, include_groups=False, - include_tags=False, include_extras=False): group_dictize_context = dict(context.items()) @@ -42,7 +41,6 @@ def group_list_dictize(obj_list, context, 'packages_field': 'dataset_count' if with_package_counts else None, # don't allow packages_field='datasets' as it is too slow 'include_groups': include_groups, - 'include_tags': include_tags, 'include_extras': include_extras, 'include_users': False, # too slow - don't allow } @@ -276,7 +274,6 @@ def get_group_dataset_counts(): def group_dictize(group, context, include_groups=True, - include_tags=True, include_users=True, include_extras=True, packages_field='datasets', @@ -357,13 +354,6 @@ def get_packages_for_this_group(group_, just_the_count=False): result_dict['package_count'] = package_count - if include_tags: - # group tags are not creatable via the API yet, but that was(/is) a - # future intention (see kindly's commit 5c8df894 on 2011/12/23) - result_dict['tags'] = tag_list_dictize( - _get_members(context, group, 'tags'), - context) - if include_groups: # these sub-groups won't have tags or extras for speed result_dict['groups'] = group_list_dictize( diff --git a/ckan/logic/action/get.py b/ckan/logic/action/get.py index 37b60949901..cc1bb056d7e 100644 --- a/ckan/logic/action/get.py +++ b/ckan/logic/action/get.py @@ -448,7 +448,7 @@ def _group_or_org_list(context, data_dict, is_org=False): group_list = [] for group in groups: data_dict['id'] = group.id - for key in ('include_extras', 'include_tags', 'include_users', + for key in ('include_extras', 'include_users', 'include_groups', 'include_followers'): if key not in data_dict: data_dict[key] = False @@ -495,9 +495,6 @@ def group_list(context, data_dict): :param include_extras: if all_fields, include the group extra fields (optional, default: ``False``) :type include_extras: bool - :param include_tags: if all_fields, include the group tags - (optional, default: ``False``) - :type include_tags: bool :param include_groups: if all_fields, include the groups the groups are in (optional, default: ``False``). :type include_groups: bool @@ -547,9 +544,6 @@ def organization_list(context, data_dict): :param include_extras: if all_fields, include the organization extra fields (optional, default: ``False``) :type include_extras: bool - :param include_tags: if all_fields, include the organization tags - (optional, default: ``False``) - :type include_tags: bool :param include_groups: if all_fields, include the organizations the organizations are in (optional, default: ``False``) @@ -1164,7 +1158,6 @@ def _group_or_org_show(context, data_dict, is_org=False): packages_field = None try: - include_tags = asbool(data_dict.get('include_tags', True)) if asbool(config.get('ckan.auth.public_user_details', True)): include_users = asbool(data_dict.get('include_users', True)) else: @@ -1189,7 +1182,6 @@ def _group_or_org_show(context, data_dict, is_org=False): group_dict = model_dictize.group_dictize(group, context, packages_field=packages_field, - include_tags=include_tags, include_extras=include_extras, include_groups=include_groups, include_users=include_users,) @@ -1246,9 +1238,6 @@ def group_show(context, data_dict): :param include_groups: include the group's sub groups (optional, default: ``True``) :type include_groups: bool - :param include_tags: include the group's tags - (optional, default: ``True``) - :type include_tags: bool :param include_followers: include the group's number of followers (optional, default: ``True``) :type include_followers: bool @@ -1281,9 +1270,6 @@ def organization_show(context, data_dict): :param include_groups: include the organization's sub groups (optional, default: ``True``) :type include_groups: bool - :param include_tags: include the organization's tags - (optional, default: ``True``) - :type include_tags: bool :param include_followers: include the organization's number of followers (optional, default: ``True``) :type include_followers: bool diff --git a/ckan/tests/lib/dictization/test_model_dictize.py b/ckan/tests/lib/dictization/test_model_dictize.py index 28a7cfbd181..06592291403 100644 --- a/ckan/tests/lib/dictization/test_model_dictize.py +++ b/ckan/tests/lib/dictization/test_model_dictize.py @@ -94,30 +94,6 @@ def test_group_list_dictize_including_extras(self): assert group_dicts[0]["extras"][0]["key"] == "k1" - def test_group_list_dictize_including_tags(self): - factories.Group() - # group tags aren't in the group_create schema, so its slightly more - # convoluted way to create them - group_obj = model.Session.query(model.Group).first() - tag = model.Tag(name="t1") - model.Session.add(tag) - model.Session.commit() - tag = model.Session.query(model.Tag).first() - group_obj = model.Session.query(model.Group).first() - member = model.Member( - group=group_obj, table_id=tag.id, table_name="tag" - ) - model.Session.add(member) - model.Session.commit() - group_list = model.Session.query(model.Group).filter_by().all() - context = {"model": model, "session": model.Session} - - group_dicts = model_dictize.group_list_dictize( - group_list, context, include_tags=True - ) - - assert group_dicts[0]["tags"][0]["name"] == "t1" - def test_group_list_dictize_including_groups(self): factories.Group(name="parent") factories.Group(name="child", groups=[{"name": "parent"}]) From 139ef7ebb4804811d6f5d36f29c9de7f61894e4c Mon Sep 17 00:00:00 2001 From: Sergey Motornyuk Date: Sat, 12 Sep 2020 12:07:12 +0300 Subject: [PATCH 002/447] Remove "tags" mention from tests --- ckan/tests/legacy/lib/test_dictization_schema.py | 1 - ckan/tests/lib/dictization/test_model_dictize.py | 1 - ckan/tests/logic/action/test_get.py | 7 ++++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/ckan/tests/legacy/lib/test_dictization_schema.py b/ckan/tests/legacy/lib/test_dictization_schema.py index 9e9ef046606..313a40b2c9b 100644 --- a/ckan/tests/legacy/lib/test_dictization_schema.py +++ b/ckan/tests/legacy/lib/test_dictization_schema.py @@ -132,7 +132,6 @@ def test_2_group_schema(self): # we don't want these here del data["groups"] del data["users"] - del data["tags"] del data["extras"] converted_data, errors = validate( diff --git a/ckan/tests/lib/dictization/test_model_dictize.py b/ckan/tests/lib/dictization/test_model_dictize.py index 06592291403..2f4d2a61fd5 100644 --- a/ckan/tests/lib/dictization/test_model_dictize.py +++ b/ckan/tests/lib/dictization/test_model_dictize.py @@ -122,7 +122,6 @@ def test_group_dictize(self): assert group["name"] == "test_dictize" assert group["packages"] == [] assert group["extras"] == [] - assert group["tags"] == [] assert group["groups"] == [] def test_group_dictize_group_with_dataset(self): diff --git a/ckan/tests/logic/action/test_get.py b/ckan/tests/logic/action/test_get.py index 7e53a64cea4..bfcb2ee3fdc 100644 --- a/ckan/tests/logic/action/test_get.py +++ b/ckan/tests/logic/action/test_get.py @@ -332,7 +332,7 @@ def test_group_list_all_fields(self): group_list = helpers.call_action("group_list", all_fields=True) expected_group = dict(group) - for field in ("users", "tags", "extras", "groups"): + for field in ("users", "extras", "groups"): del expected_group[field] assert group_list[0] == expected_group @@ -961,8 +961,9 @@ def test_user_list_order_by_created_datasets(self): ] datasets = [ factories.Dataset(user=users[1]), - factories.Dataset(user=users[1]) + factories.Dataset(user=users[1]), ] + factories.Dataset(user=users[2]) for dataset in datasets: dataset["title"] = "Edited title" helpers.call_action( @@ -971,7 +972,7 @@ def test_user_list_order_by_created_datasets(self): expected_names = [ u['name'] for u in [ users[0], # 0 packages created - users[2], # 0 packages created + users[2], # 1 packages created users[1], # 2 packages created ] ] From 0320961e7a8e3f36b1206a8c28f19849fb8bba68 Mon Sep 17 00:00:00 2001 From: Sergey Motornyuk Date: Wed, 14 Jul 2021 13:24:23 +0300 Subject: [PATCH 003/447] Allow patterns in devserver extra_paths --- ckan/cli/server.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ckan/cli/server.py b/ckan/cli/server.py index de061ed6c0f..babe16bb648 100644 --- a/ckan/cli/server.py +++ b/ckan/cli/server.py @@ -1,6 +1,8 @@ # encoding: utf-8 +import glob import logging +import itertools import click from werkzeug.serving import run_simple @@ -49,9 +51,12 @@ def run(ctx, host, port, disable_reloader, threaded, extra_files, processes, config_extra_files = tk.aslist( config.get(u"ckan.devserver.watch_patterns") ) - extra_files = list(extra_files) + [ - config[u"__file__"] - ] + config_extra_files + extra_files = itertools.chain( + [config[u"__file__"]], + *[glob.glob(path, recursive=True) + for path + in list(extra_files) + config_extra_files] + ) # Threads and processes threaded = threaded or tk.asbool(config.get(u"ckan.devserver.threaded")) From 272508b5de2789f000066727347f1778edfb917f Mon Sep 17 00:00:00 2001 From: Ian Ward Date: Wed, 14 Jul 2021 12:30:15 -0400 Subject: [PATCH 004/447] [#6118] custom url_type button for table designer --- ckanext/tabledesigner/plugin.py | 11 ++++++++++ .../snippets/resource_upload_field.html | 21 +++++++++++++++++++ setup.py | 1 + 3 files changed, 33 insertions(+) create mode 100644 ckanext/tabledesigner/plugin.py create mode 100644 ckanext/tabledesigner/templates/package/snippets/resource_upload_field.html diff --git a/ckanext/tabledesigner/plugin.py b/ckanext/tabledesigner/plugin.py new file mode 100644 index 00000000000..5c10f065d37 --- /dev/null +++ b/ckanext/tabledesigner/plugin.py @@ -0,0 +1,11 @@ +import ckan.plugins as plugins +import ckan.plugins.toolkit as toolkit + + +class TableDesignerPlugin(plugins.SingletonPlugin): + plugins.implements(plugins.IConfigurer) + + # IConfigurer + + def update_config(self, config_): + toolkit.add_template_directory(config_, "templates") diff --git a/ckanext/tabledesigner/templates/package/snippets/resource_upload_field.html b/ckanext/tabledesigner/templates/package/snippets/resource_upload_field.html new file mode 100644 index 00000000000..789d8927eba --- /dev/null +++ b/ckanext/tabledesigner/templates/package/snippets/resource_upload_field.html @@ -0,0 +1,21 @@ +{% ckan_extends %} + +{% block url_type_select %} + {{ super() }} + +{% endblock %} + +{% block url_type_fields %} + {{ super() }} + +
+ {{ remove_button() }} + +

{{ _('Use the Data Dictionary tab to customize this table.') }}

+
+{% endblock %} diff --git a/setup.py b/setup.py index 448e825ac80..cd172769c9f 100644 --- a/setup.py +++ b/setup.py @@ -74,6 +74,7 @@ 'chained_functions = ckanext.chained_functions.plugin:ChainedFunctionsPlugin', 'datastore = ckanext.datastore.plugin:DatastorePlugin', 'datapusher=ckanext.datapusher.plugin:DatapusherPlugin', + 'table_designer = ckanext.tabledesigner.plugin:TableDesignerPlugin', 'test_tag_vocab_plugin = ckanext.test_tag_vocab_plugin:MockVocabTagsPlugin', 'resource_proxy = ckanext.resourceproxy.plugin:ResourceProxy', 'text_view = ckanext.textview.plugin:TextView', From 397d3a3d98c86554e42da4b32f41b16a4d1f7177 Mon Sep 17 00:00:00 2001 From: Sergey Motornyuk Date: Thu, 9 Sep 2021 17:05:07 +0300 Subject: [PATCH 005/447] Update changelog --- changes/6254.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/6254.feature diff --git a/changes/6254.feature b/changes/6254.feature new file mode 100644 index 00000000000..0758430e884 --- /dev/null +++ b/changes/6254.feature @@ -0,0 +1 @@ +`ckan.devserver.watch_patterns` config option supports glob patterns From cb9b405732782e44ef13913134d58b8c6beb1d9e Mon Sep 17 00:00:00 2001 From: Ian Ward Date: Tue, 5 Oct 2021 18:30:18 -0400 Subject: [PATCH 006/447] [#6118] create table for table designer resources --- .../templates/datastore/dictionary.html | 2 +- .../datastore/snippets/dictionary_form.html | 16 ++++++----- ckanext/tabledesigner/actions.py | 28 +++++++++++++++++++ ckanext/tabledesigner/assets/style.css | 5 ++++ ckanext/tabledesigner/assets/webassets.yml | 5 ++++ ckanext/tabledesigner/plugin.py | 10 +++++++ .../datastore/snippets/dictionary_form.html | 8 ++++++ 7 files changed, 66 insertions(+), 8 deletions(-) create mode 100644 ckanext/tabledesigner/actions.py create mode 100644 ckanext/tabledesigner/assets/style.css create mode 100644 ckanext/tabledesigner/assets/webassets.yml create mode 100644 ckanext/tabledesigner/templates/datastore/snippets/dictionary_form.html diff --git a/ckanext/datastore/templates/datastore/dictionary.html b/ckanext/datastore/templates/datastore/dictionary.html index c6e88a4ffb1..6faefe3a5ff 100644 --- a/ckanext/datastore/templates/datastore/dictionary.html +++ b/ckanext/datastore/templates/datastore/dictionary.html @@ -11,7 +11,7 @@
{% block dictionary_form %} {% for field in fields %} - {% snippet "datastore/snippets/dictionary_form.html", field=field, position=loop.index %} + {% snippet "datastore/snippets/dictionary_form.html", field=field, position=loop.index, res=res %} {% endfor %} {% endblock %} +
+{% endblock %} + diff --git a/ckanext/tabledesigner/templates/tabledesigner/snippets/row_field.html b/ckanext/tabledesigner/templates/tabledesigner/snippets/row_field.html new file mode 100644 index 00000000000..9e2c981b26d --- /dev/null +++ b/ckanext/tabledesigner/templates/tabledesigner/snippets/row_field.html @@ -0,0 +1,5 @@ +{% import 'macros/form.html' as form %} + +{{ form.input('col__' ~ position ~ '__value', + label=field.get('info', {}).get('label', '') or field.id, classes=['control-full'], + id='field-' ~ position)}} diff --git a/ckanext/tabledesigner/views.py b/ckanext/tabledesigner/views.py index ec66cfed55c..ed66f77a440 100644 --- a/ckanext/tabledesigner/views.py +++ b/ckanext/tabledesigner/views.py @@ -7,7 +7,13 @@ tuplize_dict, parse_params, ) -from ckan.plugins.toolkit import get_action, h, _, request +from ckan.plugins.toolkit import ( + get_action, + h, + _, + request, + render, +) tabledesigner = Blueprint(u'tabledesigner', __name__) @@ -58,3 +64,39 @@ def post(self, id, resource_id): '/dataset//dictionary/', view_func=_TableDesignerDictionary.as_view('tabledesigner'), ) + + +class _TableDesignerAddRow(MethodView): + def post(self, id, resource_id): + pass + + def get(self, id, resource_id): + _datastore_view = DictionaryView() + data_dict = _datastore_view._prepare(id, resource_id) + return render('tabledesigner/add_row.html', data_dict) + + def post(self, id, resource_id): + _datastore_view = DictionaryView() + data_dict = _datastore_view._prepare(id, resource_id) + + data = dict_fns.unflatten(tuplize_dict(parse_params(request.form))) + col = data.get('col', []) + row = {} + for f, c in zip(data_dict['fields'], col): + row[f['id']] = c['value'] or None + + get_action('datastore_upsert')( + None, { + 'resource_id': resource_id, + 'method': 'insert', + 'force': True, # FIXME: don't require this for tabledesigner tables + 'records': [row], + } + ) + return h.redirect_to(data_dict['pkg_dict']['type'] + '_resource.read', id=id, resource_id=resource_id) + + +tabledesigner.add_url_rule( + '/dataset//tabledesigner//add-row', + view_func=_TableDesignerAddRow.as_view('add_row'), +) From 2091e8ecb9ef7162f28c0b9d8c4f650cedd01abc Mon Sep 17 00:00:00 2001 From: Ian Ward Date: Mon, 20 Dec 2021 17:57:41 -0500 Subject: [PATCH 015/447] basic edit row functionality --- .../templates/package/resource_read.html | 19 +++++-- .../templates/tabledesigner/edit_row.html | 23 ++++++++ .../tabledesigner/snippets/row_field.html | 10 ++-- ckanext/tabledesigner/views.py | 52 +++++++++++++++++-- 4 files changed, 95 insertions(+), 9 deletions(-) create mode 100644 ckanext/tabledesigner/templates/tabledesigner/edit_row.html diff --git a/ckanext/tabledesigner/templates/package/resource_read.html b/ckanext/tabledesigner/templates/package/resource_read.html index 07def694803..b644d5dc9e8 100644 --- a/ckanext/tabledesigner/templates/package/resource_read.html +++ b/ckanext/tabledesigner/templates/package/resource_read.html @@ -1,14 +1,27 @@ {% ckan_extends %} +{% import 'macros/form.html' as form %} + {% block resource_additional_information_inner %} {% if res.url_type == 'tabledesigner' and res.datastore_active %} {% block resource_tabledesigner %}

{{ _('Table Designer') }}

+ {% block resource_tabledesigner_edit %} +
{{ form.input('_id', label='_id', classes=['control-full'], id='_id', is_required=true) }} + +
+ {% endblock %} {% block resource_tabledesigner_add %} - {% block add_row_button_text %} {{ _('Add Row') }}{% endblock %} +

+ {% block add_row_button_text %} {{ _('Add Row') }}{% endblock %} +

{% endblock %}
{% endblock %} diff --git a/ckanext/tabledesigner/templates/tabledesigner/edit_row.html b/ckanext/tabledesigner/templates/tabledesigner/edit_row.html new file mode 100644 index 00000000000..2d2c2082b2d --- /dev/null +++ b/ckanext/tabledesigner/templates/tabledesigner/edit_row.html @@ -0,0 +1,23 @@ +{% extends "package/resource_edit_base.html" %} + +{% import 'macros/form.html' as form %} + +{% block subtitle %}{{ h.dataset_display_name(pkg) }} - {{ h.resource_display_name(res) }}{% endblock %} + +{% block primary_content_inner %} + + {% set action = h.url_for('tabledesigner.edit_row', id=pkg.name, resource_id=res.id) %} +

{{ _('Edit row') }}

+ +
+ {% block add_row %} + {% for field in fields %} + {% snippet "tabledesigner/snippets/row_field.html", field=field, position=loop.index, res=res, value=row.get(field.id) %} + {% endfor %} + {% endblock %} + +
+{% endblock %} + diff --git a/ckanext/tabledesigner/templates/tabledesigner/snippets/row_field.html b/ckanext/tabledesigner/templates/tabledesigner/snippets/row_field.html index 9e2c981b26d..2e31065415c 100644 --- a/ckanext/tabledesigner/templates/tabledesigner/snippets/row_field.html +++ b/ckanext/tabledesigner/templates/tabledesigner/snippets/row_field.html @@ -1,5 +1,9 @@ {% import 'macros/form.html' as form %} -{{ form.input('col__' ~ position ~ '__value', - label=field.get('info', {}).get('label', '') or field.id, classes=['control-full'], - id='field-' ~ position)}} +{{ + form.input('col__' ~ position ~ '__value', + label=field.get('info', {}).get('label', '') or field.id, classes=['control-full'], + id='field-' ~ position, + value=value or '', + ) +}} diff --git a/ckanext/tabledesigner/views.py b/ckanext/tabledesigner/views.py index ed66f77a440..822172241c8 100644 --- a/ckanext/tabledesigner/views.py +++ b/ckanext/tabledesigner/views.py @@ -7,6 +7,8 @@ tuplize_dict, parse_params, ) +from ckan.lib import base +from ckan.logic import NotAuthorized from ckan.plugins.toolkit import ( get_action, h, @@ -67,9 +69,6 @@ def post(self, id, resource_id): class _TableDesignerAddRow(MethodView): - def post(self, id, resource_id): - pass - def get(self, id, resource_id): _datastore_view = DictionaryView() data_dict = _datastore_view._prepare(id, resource_id) @@ -100,3 +99,50 @@ def post(self, id, resource_id): '/dataset//tabledesigner//add-row', view_func=_TableDesignerAddRow.as_view('add_row'), ) + + +class _TableDesignerEditRow(MethodView): + def get(self, id, resource_id): + _datastore_view = DictionaryView() + data_dict = _datastore_view._prepare(id, resource_id) + _id = request.params['_id'] + + try: + r = get_action('datastore_search')( + None, { + 'resource_id': resource_id, + 'filters': {'_id': _id}, + } + ) + except NotAuthorized: + return base.abort(403, _('Not authorized to see this page')) + if not r['records']: + return base.abort(404, _('Row not found')) + data_dict['row'] = r['records'][0] + return render('tabledesigner/edit_row.html', data_dict) + + def post(self, id, resource_id): + _datastore_view = DictionaryView() + data_dict = _datastore_view._prepare(id, resource_id) + _id = request.params['_id'] + + data = dict_fns.unflatten(tuplize_dict(parse_params(request.form))) + col = data.get('col', []) + row = {'_id': _id} + for f, c in zip(data_dict['fields'], col): + row[f['id']] = c['value'] or None + + get_action('datastore_upsert')( + None, { + 'resource_id': resource_id, + 'method': 'update', + 'force': True, # FIXME: don't require this for tabledesigner tables + 'records': [row], + } + ) + return h.redirect_to(data_dict['pkg_dict']['type'] + '_resource.read', id=id, resource_id=resource_id) + +tabledesigner.add_url_rule( + '/dataset//tabledesigner//edit-row', + view_func=_TableDesignerEditRow.as_view('edit_row'), +) From 826046a25cb13e090d64f6a94f8c8382f08964f1 Mon Sep 17 00:00:00 2001 From: Sergey Motornyuk Date: Mon, 21 Feb 2022 10:35:14 +0200 Subject: [PATCH 016/447] Update types --- ckan/cli/server.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ckan/cli/server.py b/ckan/cli/server.py index 9585a50e9dd..d0d354834e1 100644 --- a/ckan/cli/server.py +++ b/ckan/cli/server.py @@ -5,7 +5,7 @@ import itertools import logging import warnings -from typing import Optional +from typing import Iterable, Optional import click from werkzeug.serving import run_simple @@ -47,7 +47,7 @@ " automatically generate a new one (on each server reload).") @click.pass_context def run(ctx: click.Context, host: str, port: str, disable_reloader: bool, - threaded: bool, extra_files: list[str], processes: int, + threaded: bool, extra_files: Iterable[str], processes: int, ssl_cert: Optional[str], ssl_key: Optional[str]): u"""Runs the Werkzeug development server""" From 1d1c083a695ad40ea4cd6184f219dc94a259097c Mon Sep 17 00:00:00 2001 From: Ian Ward Date: Mon, 12 Sep 2022 13:36:11 -0400 Subject: [PATCH 017/447] [#6118] restore plugin after setup.py change --- setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.cfg b/setup.cfg index 2df3ecc8487..e34dd48f3b6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -72,6 +72,7 @@ ckan.plugins = recline_grid = ckanext.reclineview.plugin:ReclineGridView recline_graph = ckanext.reclineview.plugin:ReclineGraphView recline_map = ckanext.reclineview.plugin:ReclineMapView + tabledesigner = ckanext.tabledesigner.plugin:TableDesignerPlugin example_itemplatehelpers = ckanext.example_itemplatehelpers.plugin:ExampleITemplateHelpersPlugin example_idatasetform = ckanext.example_idatasetform.plugin:ExampleIDatasetFormPlugin example_idatasetform_inherit = ckanext.example_idatasetform.plugin:ExampleIDatasetFormInheritPlugin From 90d8c6f73e2599d93f3d8458c4cc45820a9ea134 Mon Sep 17 00:00:00 2001 From: Ian Ward Date: Mon, 26 Sep 2022 14:18:05 -0400 Subject: [PATCH 018/447] [#6118] display error on duplicate pk --- .../templates/tabledesigner/add_row.html | 2 +- .../templates/tabledesigner/edit_row.html | 2 +- .../tabledesigner/snippets/row_field.html | 1 + ckanext/tabledesigner/views.py | 35 ++++++++++++++----- 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/ckanext/tabledesigner/templates/tabledesigner/add_row.html b/ckanext/tabledesigner/templates/tabledesigner/add_row.html index 4b898698af5..955118468aa 100644 --- a/ckanext/tabledesigner/templates/tabledesigner/add_row.html +++ b/ckanext/tabledesigner/templates/tabledesigner/add_row.html @@ -12,7 +12,7 @@

{{ _('Add row') }}

{% block add_row %} {% for field in fields %} - {% snippet "tabledesigner/snippets/row_field.html", field=field, position=loop.index, res=res %} + {% snippet "tabledesigner/snippets/row_field.html", field=field, position=loop.index, res=res, value=row.get(field.id), errors=errors %} {% endfor %} {% endblock %} + +
+
+ {{ _('Get 5 results containing "jones" in any field:') }} + {% for clang in code_languages %} + {{ code_examples[clang]['request_limit'] }} + {% endfor %} + + + {{ _('Get results with either "watershed" or "survey" as subject and "active" as its stage:') }} + {% for clang in code_languages %} + {{ code_examples[clang]['request_filter'] }} + {% endfor %} + + {% if h.datastore_search_sql_enabled() %} + {{ _('SQL query example:') }} + {% for clang in code_languages %} + {{ code_examples[clang]['request_sql'] }} + {% endfor %} + {% endif %} +
+
+ +
+

+ +

+
+
+ +
+
+
+
+

+ +

+
+
+ +
+
+
+ {% else %} + {{ super() }} + {% endif %} +{% endblock %} From 2c7f62882eb2ada70f534b6d6f07fcdf3366d863 Mon Sep 17 00:00:00 2001 From: Ian Ward Date: Tue, 30 May 2023 17:04:15 -0400 Subject: [PATCH 039/447] [#6118] dynamic query, insert, update, delete parameters --- .../templates/ajax_snippets/api_info.html | 10 +- .../datastore/api_examples/curl.html | 3 + .../datastore/api_examples/javascript.html | 3 + .../datastore/api_examples/powershell.html | 2 + .../datastore/api_examples/python.html | 2 + .../templates/datastore/api_examples/r.html | 3 + ckanext/tabledesigner/helpers.py | 27 ++++- .../templates/ajax_snippets/api_info.html | 37 +++++-- .../datastore/api_examples/curl.html | 61 +++++++++++ .../datastore/api_examples/javascript.html | 102 ++++++++++++++++++ .../datastore/api_examples/powershell.html | 75 +++++++++++++ .../datastore/api_examples/python.html | 66 ++++++++++++ .../templates/datastore/api_examples/r.html | 93 ++++++++++++++++ 13 files changed, 469 insertions(+), 15 deletions(-) create mode 100644 ckanext/tabledesigner/templates/datastore/api_examples/curl.html create mode 100644 ckanext/tabledesigner/templates/datastore/api_examples/javascript.html create mode 100644 ckanext/tabledesigner/templates/datastore/api_examples/powershell.html create mode 100644 ckanext/tabledesigner/templates/datastore/api_examples/python.html create mode 100644 ckanext/tabledesigner/templates/datastore/api_examples/r.html diff --git a/ckanext/datastore/templates/ajax_snippets/api_info.html b/ckanext/datastore/templates/ajax_snippets/api_info.html index ae484105358..aff89590153 100644 --- a/ckanext/datastore/templates/ajax_snippets/api_info.html +++ b/ckanext/datastore/templates/ajax_snippets/api_info.html @@ -20,10 +20,12 @@ {% set code_languages = ['curl', 'javascript', 'powershell', 'python', 'r'] %} -{# register examples by including templates here #} -{% for clang in code_languages %} - {% include "/datastore/api_examples/" + clang + ".html" %} -{% endfor %} +{% block register_examples %} + {# register examples by including templates here #} + {% for clang in code_languages %} + {% include "/datastore/api_examples/" + clang + ".html" %} + {% endfor %} +{% endblock %}