GithubHelp home page GithubHelp logo

ckanext-scheming's Introduction

ckanext-scheming

This CKAN extension provides a way to configure and share metadata schemas using a YAML or JSON schema description. Custom validation and template snippets for editing and display are supported.

Tests

Table of contents:

  1. Requirements
  2. Installation
  3. Configuration
  4. Action API Endpoints
  5. Running the Tests

Requirements

This plugin is compatible with CKAN 2.9 or later.

Installation

You can install the extension with the following shell commands:

cd $CKAN_VENV/src/

pip install -e "git+https://github.com/ckan/ckanext-scheming.git#egg=ckanext-scheming"

Configuration

Set the schemas you want to use with configuration options:

# Each of the plugins is optional depending on your use
ckan.plugins = scheming_datasets scheming_groups scheming_organizations

#   module-path:file to schemas being used
scheming.dataset_schemas = ckanext.spatialx:spatialx_schema.yaml
                           ckanext.spatialx:spatialxy_schema.yaml
#   will try to load "spatialx_schema.yaml" and "spatialxy_schema.yaml"
#   as dataset schemas

#   For group and organization schemas (replace myplugin with your custom plugin)
scheming.group_schemas = ckanext.scheming:group_with_bookface.json
                         ckanext.myplugin:/etc/ckan/default/group_with_custom_fields.json
scheming.organization_schemas = ckanext.scheming:org_with_dept_id.json
                                ckanext.myplugin:org_with_custom_fields.json
#
#   URLs may also be used, e.g:
#
# scheming.dataset_schemas = http://example.com/spatialx_schema.yaml

#   Preset files may be included as well. The default preset setting is:
scheming.presets = ckanext.scheming:presets.json

#   The is_fallback setting may be changed as well. Defaults to false:
scheming.dataset_fallback = false

Schema Types

With this plugin, you can customize the group, organization, and dataset entities in CKAN. Adding and enabling a schema will modify the forms used to update and create each entity, indicated by the respective type property at the root level. Such as group_type, organization_type, and dataset_type. Non-default types are supported properly as is indicated throughout the examples.

Example Schemas

Dataset schemas:

These schemas are included in ckanext-scheming and may be enabled with e.g: scheming.dataset_schemas = ckanext.scheming:camel_photos.yaml

These schemas use presets defined in presets.json.

Group schemas:

Organization schemas:

Common Schema Keys

scheming_version

Set to 2. Future versions of ckanext-scheming may use a larger number to indicate a change to the schema format.

about_url

about_url: https://github.com/link-to-my-project

about_url is a link to human-readable information about this schema. ckanext-scheming automatically publishes your schema and this link allows users to learn more about it.

Dataset Schema Keys

dataset_type

dataset_type: camel-photos

This is the "type" field stored in the dataset. It is also used to set the URL for searching this type of dataset.

Normal datasets would be available under the URL /dataset, but datasets with the camel_photos.json schema above would appear under /camel-photos instead.

dataset_fields, resource_fields

dataset_fields:

- field_name: title
  label: Title
  preset: title

- field_name: name
  label: URL
  preset: dataset_slug

...

Fields are specified in the order you would like them to appear in the dataset and resource editing pages.

Fields you exclude will not be shown to the end user, and will not be accepted when editing or updating this type of dataset.

Group / Organization Schema Keys

group_type

group_type: group

is used for modifying the default group schema

group_type: theme

is an example of defining a custom group type, as seen in the example schemas above

Like dataset_type, a group_type of group allows you to customize the default group schema under the URL /group, such as the modified schema in group_with_bookface.json, but a schema with a custom type such as custom_group_with_status.json schema above would appear under /theme instead, because its group_type field is set to "theme".

organization_type

organization_type: organization

is used for modifying the default organization schema

organization_type: publisher

is an example of defining a custom organization type, as seen in the example schemas above

fields

fields:

- field_name: title
  label: Name
  form_snippet: large_text.html
  form_attrs:
    data_module: slug-preview-target
  form_placeholder: My Organization

...

A single fields list replaces the dataset_fields and resource_fields schema properties doin dataset schemas.


Field Keys

field_name

The field_name value is the name of an existing CKAN dataset or resource field or a new extra field. Existing dataset field names include:

  • name - the URI for the dataset
  • title
  • notes - the dataset description
  • author
  • author_email
  • maintainer
  • maintainer_email

New field names should follow the current lowercase_with_underscores naming convention. Don't name your field mySpecialField, use my_special_field instead.

label

The label value is a human-readable label for this field as it will appear in the dataset editing form. This label may be a string or an object providing multiple language versions:

- field_name: title
  label:
    en: Title
    fr: Titre

When using a plain string translations will be provided with gettext:

- field_name: title
  label: Title

repeating_subfields

This field is the parent of group of repeating subfields. The value is a list of fields entered the same way as normal fields.

NOTE: CKAN needs an IPackageController plugin with before_index to convert repeating subfields to formats that can be indexed by solr. For testing you may use the included scheming_nerf_index plugin to encode all repeating fields as JSON strings to prevent solr errors.

repeating_label may be used to provide a singular version of the label for each group.

- field_name: contacts
  label: Contacts
  repeating_label: Contact
  repeating_subfields:

  - field_name: address
    label: Address
    required: true

  - field_name: city
    label: City

  - field_name: phone
    label: Phone Number

start_form_page

Dataset fields may be divided into separate form pages for creation and editing. CKAN 2.9+ only. Form pages for dataset type only supported by CKAN 2.10+ or with ckan/ckan#7032 . Adding start_form_page to a field marks this field as the start of a new page of fields.

- start_form_page:
    title: Detailed Metadata
    description:
      These fields improve search and give users important links

  field_name: address
  label: Address

A title and description should be provided to help with navigation. These values may be strings or objects providing multiple language versions of text.

required

  required: true

Use for fields that must be included. Set to false or don't include this key for fields that are optional.

Setting to true will mark the field as required in the editing form and include not_empty in the default validators that will be applied when validators is not specified.

NOTE: To honor this settings with custom validators include scheming_required as the first validator. scheming_required will check the required setting for this field and apply either the not_empty or ignore_missing validator.

choices

The choices list may be provided for select and multiple choice fields. List elements include labels for human-readable text for each element (may be multiple languages like a field label) and values that will be stored in the dataset or resource:

- field_name: category
  preset: select
  choices:
  - value: bactrian
    label: Bactrian Camel
  - value: hybrid
    label: Hybrid Camel

For storing non-string values see output_validators.

For required select fields you may also want to add this setting so that users are forced to choose an item in the form, otherwise the first choice will be selected in the form by default:

  form_include_blank_choice: true

To set the number of choices displayed in the multiple_select form snippets use:

  select_size: 5

To sort choices alphabetically in form and display snippets use:

  sorted_choices: true

choices_helper

If a choices list is not provided you must provide a choices_helper function that will return a list of choices in the same format as the choices list above.

You may register your own helper function or use the scheming_datastore_choices helper included in ckanext-scheming:

- field_name: country
  preset: select
  choices_helper: scheming_datastore_choices
  datastore_choices_resource: countries-resource-id-or-alias
  datastore_choices_columns:
    value: Country Code
    label: English Country Name
  datastore_additional_choices:
  - value: none
    label: None
  - value: na
    label: N/A

preset

A preset specifies a set of default values for other field keys. They allow reuse of definitions for validation and snippets for common field types.

This extension includes the following presets in presets.json:

  preset: title

title validation and large text form snippet

  preset: select

validation that choice is from choices, form select box and display snippet

  preset: radio

validation that choice is from choices, form radio buttons group and display snippet

  preset: multiple_checkbox

multiple choice from choices rendered as checkboxes in the form, stored as a list of values

  preset: multiple_select

multiple choice from choices rendered as a multiple select box in the form, stored as a list of values

  preset: multiple_text

repeating text field with add and remove buttons, stored as a list of strings

  preset: date

date validation and form snippet

  preset: datetime

date and time validation and form snippet

  preset: dataset_slug

dataset slug validation and form snippet that autofills the value from the title field

  preset: tag_string_autocomplete

tag string validation and form autocomplete

  preset: dataset_organization

organization validation and form select box

  preset: resource_url_upload

resource url validaton and link/upload form field

  preset: resource_format_autocomplete

resource format validation and form autocomplete

  preset: organization_url_upload

organization url validaton and link/upload form field format guessing based on url and autocompleting form field

  preset: json_object

JSON based input. Only JSON objects are supported. The input JSON will be loaded during output (eg when loading the dataset in a template or via the API

  preset: markdown

markdown text area and display

You may define your own presets by adding additional files to the scheming.presets configuration setting.

form_snippet

The form_snippet value is the name of the snippet template to use for this field in the dataset or resource editing form. A number of snippets are provided with this extension, but you may also provide your own by creating templates under scheming/form_snippets/ in a template directory in your own extension.

This snippet is passed the field dict containing all the keys and values in this field record, including any additional ones you added to your that aren't handled by this extension.

The included form snippets may be found under templates/scheming/form_snippets.

display_snippet

The display_snippet value is the name of the snippet template to use for this field in the dataset, resource, group or organization view page. A number of snippets are provided with this extension, but you may also provide your own by creating templates under scheming/display_snippets/ in a template directory in your own extension.

This snippet is passed the field dict containing all the keys and values in this field record, including any additional ones you added to your that aren't handled by this extension.

The included display snippets may be found under templates/scheming/display_snippets.

If display_snippet: null is used the field will be removed from the view page.

display_property

- field_name: author
  label: Author
  display_property: dc:creator

Set a property attribute on dataset fields displayed as "Additional Info", useful for adding RDF markup.

validators

The validators value is a space-separated string of validator and converter functions to use for this field when creating or updating data. When a validator name is followed by parenthesis the function is called passing the comma-separated values within and the result is used as the validator/converter.

  validators: if_empty_same_as(name) unicode_safe

is the same as a plugin using the validators:

[get_validator('if_empty_same_as')("name"), unicode_safe]

If parameters can be parsed as a valid python literals, they are passed with original type. If not, all parameters passed as strings. In addition, space character is not allowed in argument position. Use its HEX code instead \\x20.

  validators: xxx(hello,world)    # xxx("hello", "world")
  validators: xxx(hello,1)        # xxx("hello", "1")
  validators: xxx("hello",1,None) # xxx("hello", 1, None)
  validators: xxx("hello\\x20world") # xxx("hello world")

This string does not contain arbitrary python code to be executed, you may only use registered validator functions, optionally calling them with static string values provided.

NOTE: ckanext-scheming automatically adds calls to convert_to_extras for extra fields when required.

New validators and converters may be added using the IValidators plugin interface.

Validators that need access to other values in this schema (e.g. to test values against the choices list) may be decorated with the scheming.validation.scheming_validator function. This decorator will make scheming pass this field dict to the validator and use its return value for validation of the field.

CKAN's validator functions reference lists available validators ready to be used.

output_validators

Internally all extra fields are stored as strings. If you are attempting to save and restore other types of data you will need to use output validators.

For example if you use a simple "yes/no" question, you will need to let ckanext-scheming know that this data needs to be stored and retrieved as a boolean. This is acheieved using validators and output_validators keys.

  - field_name: is_camel_friendly
    label: Is this camel friendly?
    required: true
    preset: select
    choices:
      - value: false
        label: "No"
      - value: true
        label: "Yes"
    validators: scheming_required boolean_validator
    output_validators: boolean_validator

The output_validators value is like validators but used when retrieving values from the database instead of when saving them. These validators may be used to transform the data before it is sent to the user.

NOTE: ckanext-scheming automatically adds calls to convert_from_extras for extra fields when required.

create_validators

The create_validators value if present overrides validators during create only.

help_text

  help_text: License definitions and additional information

If this key is supplied, its value will be shown after the field as help text. Help text may be provided in multiple languages like label fields.

Help text must be plain text, no markdown or HTML are allowed unless:

  help_allow_html: true

Allow HTML inside the help text if set to true. Default is false.

Adjust the position of help_text with:

  help_inline: true

Display help text inline (next to the field) if set to true. Default is false (display help text under the field).

Action API Endpoints

The extension adds action endpoints which expose any configured schemas via: https://github.com/ckan/ckanext-scheming/blob/master/ckanext/scheming/logic.py

Some examples:

Calling http://localhost:5000/api/3/action/scheming_dataset_schema_list

Returns:

{
  help: "http://localhost:5005/api/3/action/help_show?name=scheming_dataset_schema_list",
  success: true,
  result: [
    "dataset",
    "camel-photos"
  ]
}

Calling http://localhost:5000/api/3/action/scheming_dataset_schema_show?type=dataset

Returns:

{
  help: "http://localhost:5005/api/3/action/help_show?name=scheming_dataset_schema_show",
  success: true,
  result: {
    scheming_version: 2,
    dataset_type: "dataset",
    about: "A reimplementation of the default CKAN dataset schema",
    about_url: "http://github.com/ckan/ckanext-scheming",
    dataset_fields: [...],
    resource_fields: [...]
  }
}

The full list of API actions are available in ckanext/scheming/logic.py

Running the Tests

To run the tests:

pytest --ckan-ini=test.ini ckanext/scheming/tests

ckanext-scheming's People

Contributors

agmorev avatar amercader avatar avdata99 avatar benjaminlaot avatar boykoc avatar brew avatar bzar avatar ccancellieri avatar cole-fields avatar deniszgonjanin avatar engerrs avatar fanjinfei avatar habibayoub avatar howff avatar jqnatividad avatar jvickery-tbs avatar kourylape avatar laurentgoderre avatar luketully avatar mattfullerton avatar maxfredenburgh avatar rabiasajjad avatar roc avatar samuelbradley avatar smotornyuk avatar themowski avatar thriuin avatar tktech avatar wardi avatar zharktas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ckanext-scheming's Issues

Failure on cloning code 128

As above, when trying to clone : sudo pip install -e "git+https://github.com/open-data/ckanext-scheming.git#egg=ckanext-scheming"

Output:
Obtaining ckanext-scheming from git+
https://github.com/open-data/ckanext-scheming.git#egg=ckanext-scheming
Cloning
https://github.com/open-data/ckanext-scheming.git to ./src/ckanext-scheming
fatal: I don't handle protocol '
https'
Complete output from command /usr/bin/git clone -q "
https://github.com/open-data/ckanext-scheming.git" /home/ckan/ckan/lib/default/src/ckan/src/ckanext-scheming:


Command /usr/bin/git clone -q "
https://github.com/open-data/ckanext-scheming.git" /home/ckan/ckan/lib/default/src/ckan/src/ckanext-scheming failed with error code 128

I have installed the most recent MASTER of ckan/ckan and have it running with a development.ini configuration. The project I am a part of at Swedens Agricultural University would really like to get going with CKAN and the scheming extension. Any help gratefully received.

Correct usage of scheming

Hi,

Below is a .json schema I would like to implement. It is about 60% of the final schema we have planned. I have not added all the relevent fluent parts as all labels will be available in swedish and english. I was hoping you could run your eye over it for me as it is the first I have written. My development.ini file additions looks like this:

scheming.dataset_schemas = ckanext.scheming:ckan.json
                                                 ckanext.scheming:camel_photos.json
                                                 ckanext.scheming:sluschemav014.json

scheming.presets = ckanext.scheming:presets.json
                                ckanext.fluent:presets.json
                                ckanext.repeating:presets.json

Also: scheming-datasets has been added to my plugins list

When I serve the development.ini file, ckan seems to run AOK, I have checked and the plugins are all loading but I do not know how to get any of the schemas to actually appear when a new dataset is created. Should this be automatic? If you have multiple schemas, does the author chose which to use?

sluschemav014.json

{
  "scheming_version": 1,
  "dataset_type": "SLU Base Metadata schema v014",
  "about_url": "http://tilda.slu.se/base-schema-v014",
  "dataset_fields": [
    {
      "field_name": "metadatalanguage",
      "label": "MetaDataLanguage",
      "help_text": "Which language will you use?",
      "help_inline": true,
      "preset": "English",
      "choices": [
        {
          "value": "english",
          "label": "English"
        },
        {
          "value": "swedish",
          "label": "Swedish"
        }
      ]
    },
    {
      "field_name": "mdcOrganisation",
      "label": "Organisation",
      "help_text": "Which organisation?",
      "help_inline": true,
      "preset": "Sveriges lantbruksuniversitet (SLU)",
      "form_placeholder": "eg. SLU",
      "choices": [
        {
          "value": "sveriges lantbruksuniversitet (slu)",
          "label": "Sveriges lantbruksuniversitet (SLU)"
        },
        {
          "value": "swedish university of agricultural sciences",
          "label": "Swedish University of Agricultural Sciences"
        }
      ]
    },
    {
      "field_name": "mdcPerson",
      "label": "Person",
      "preset": "person",
      "form_placeholder": "eg. John Smith",
      "display_property": "dc:creator"
    },
    {
      "field_name": "mdcEMail",
      "label": "EMail",
      "preset": "email",
      "form_placeholder": "[email protected]",
      "display_property": "dc:creator",
      "display_snippet": "email.html",
      "display_email_name_field": "mdcPerson"
    },
    {
      "field_name": "mdcRole",
      "label": "Role",
      "help_text": "What role?",
      "help_inline": true,
      "preset": "pointOfContact - kontakt",
      "form_placeholder": "eg. point of contact",
      "choices": [
        {
          "value": "pointOfContact - kontakt",
          "label": {"en": "pointOfContact","sv": "kontakt"}
        },
        {
          "value": "principalInvestigator - undersökningsansvarig",
          "label": {"en": "principalInvestigator","sv": "undersökningsansvarig"}
        },
        {
          "value": "author - upphovsman",
          "label": {"en": "author","sv": "upphovsman"}
        },
        {
          "value": "originator - producent",
          "label": {"en": "originator","sv": "producent"}
        },
        {
          "value": "custodian - förvaltare",
          "label": {"en": "custodian","sv": "förvaltare"}
        },
        {
          "value": "owner - ägare",
          "label": {"en": "owner","sv": "ägare"}
        },
        {
          "value": "processor - vidareförädlare",
          "label": {"en": "processor","sv": "vidareförädlare"}
        },
        {
          "value": "publisher - utgivare",
          "label": {"en": "publisher","sv": "utgivare"}
        },
        {
          "value": "distributor - distributör",
          "label": {"en": "distributor","sv": "distributör"}
        },
        {
          "value": "resourceProvider - leverantör",
          "label": {"en": "resourceProvider","sv": "leverantör"}
        }
      ]
    },
    {
      "field_name": "metadata_date",
      "label": "Dataset date",
      "preset": "date"
    },
    {
      "field_name": "md_standard",
      "label": "Metadata Standard"
    },
    {
      "field_name": "md_standardversion",
      "label": "Metadata Standard version"
    },
    {
      "field_name": "resourcetype",
      "label": "Resource Type",
      "help_text": "What type is the resource?",
      "help_inline": true,
      "preset": "dataset - datamängder",
      "form_placeholder": "eg. dataset",
      "choices": [
        {
          "value": "dataset - datamängder",
          "label": {"en": "dataset","sv": "datamängder"}
        },
        {
          "value": "series - serier av datamängder",
          "label": {"en": "series","sv": "serier av datamängder"}
        },
        {
          "value": "service - tjänster",
          "label": {"en": "service","sv": "tjänster"}
        },
        {
          "value": "software - applikationer",
          "label": {"en": "software","sv": "applikationer"}
        }
      ]
    },
    {
      "field_name": "guidurl",
      "label": "Unique URL",
      "form_placeholder": "http://tilda.slu.se/dataset",
      "display_property": "foaf:homepage",
      "display_snippet": "link.html"
    },
    {
      "field_name": "title",
      "preset": "fluent_text",
      "label": {
         "en": "Title",
         "sv": "Titel"
    },
      "form_languages": ["en", "sv"]
    },
    {
      "field_name": "version",
      "label": "Version of the dataset",
      "validators": "ignore_missing unicode package_version_validator",
      "form_placeholder": "1.0"
    },
    {
      "field_name": "ds_citations",
      "label": {"en": "Quoting data sets", "se": "Citering av dataset"}
    },    
    {
      "field_name": "reference_date",
      "label": "Reference date",
      "preset": "date"
    },
    {
      "field_name": "resource_event",
      "label": "Resource Event",
      "help_text": "What event?",
      "help_inline": true,
      "preset": "creation - skapades",
      "form_placeholder": "eg. creation",
      "choices": [
        {
          "value": "creation - skapades",
          "label": {"en": "creation","sv": "skapades"}
        },
        {
          "value": "publication - publicerades",
          "label": {"en": "publication","sv": "publicerades"}
        },
        {
          "value": "revision - reviderades",
          "label": {"en": "revision","sv": "reviderades"}
        }
      ]
    },
    {
      "field_name": "resource_status",
      "label": "Resource Status",
      "help_text": "Which status is the resource at?",
      "help_inline": true,
      "preset": "planned - planerad",
      "form_placeholder": "eg. planned",
      "choices": [
        {
          "value": "planned - planerad",
          "label": {"en": "planned","sv": "planerad"}
        },
        {
          "value": "underDevelopment - under utveckling",
          "label": {"en": "under development","sv": "under utveckling"}
        },
        {
          "value": "onGoing - pågående/driftsatt",
          "label": {"en": "on going","sv": "pågående/driftsatt"}
        },
        {
          "value": "completed - färdigställd",
          "label": {"en": "completed","sv": "färdigställd"}
        },
        {
          "value": "historicalArchive - arkiverad",
          "label": {"en": "historical archive","sv": "arkiverad"}
        },
        {
          "value": "obsolete - inte längre i bruk",
          "label": {"en": "obsolete","sv": "inte längre i bruk"}
        },
        {
          "value": "required - åtgärd krävs",
          "label": {"en": "required","sv": "åtgärd krävs"}
        }
      ]
    },
    {
      "field_name": "rcOrganisation",
      "label": "Organisation",
      "help_text": "Which organisation?",
      "help_inline": true,
      "preset": "Sveriges lantbruksuniversitet (SLU)",
      "form_placeholder": "eg. SLU",
      "choices": [
        {
          "value": "sveriges lantbruksuniversitet (slu)",
          "label": "Sveriges lantbruksuniversitet (SLU)"
        },
        {
          "value": "swedish university of agricultural sciences",
          "label": "Swedish University of Agricultural Sciences"
        }
      ]
    },
    {
      "field_name": "rcPerson",
      "label": "Person",
      "preset": "person",
      "form_placeholder": "eg. John Smith",
      "display_property": "dc:creator"
    },
    {
      "field_name": "rcEMail",
      "label": "EMail",
      "preset": "email",
      "form_placeholder": "[email protected]",
      "display_property": "dc:creator",
      "display_snippet": "email.html",
      "display_email_name_field": "mdcPerson"
    },
    {
      "field_name": "rcRole",
      "label": "Role",
      "help_text": "What role?",
      "help_inline": true,
      "preset": "pointOfContact - kontakt",
      "form_placeholder": "eg. point of contact",
      "choices": [
        {
          "value": "pointOfContact - kontakt",
          "label": {"en": "pointOfContact","sv": "kontakt"}
        },
        {
          "value": "principalInvestigator - undersökningsansvarig",
          "label": {"en": "principalInvestigator","sv": "undersökningsansvarig"}
        },
        {
          "value": "author - upphovsman",
          "label": {"en": "author","sv": "upphovsman"}
        },
        {
          "value": "originator - producent",
          "label": {"en": "originator","sv": "producent"}
        },
        {
          "value": "custodian - förvaltare",
          "label": {"en": "custodian","sv": "förvaltare"}
        },
        {
          "value": "owner - ägare",
          "label": {"en": "owner","sv": "ägare"}
        },
        {
          "value": "processor - vidareförädlare",
          "label": {"en": "processor","sv": "vidareförädlare"}
        },
        {
          "value": "publisher - utgivare",
          "label": {"en": "publisher","sv": "utgivare"}
        },
        {
          "value": "distributor - distributör",
          "label": {"en": "distributor","sv": "distributör"}
        },
        {
          "value": "resourceProvider - leverantör",
          "label": {"en": "resourceProvider","sv": "leverantör"}
        }
      ]
    },
    {
      "field_name": "resource_id",
      "label": "Resource ID"
    },
    {
      "field_name": "resource_id_code",
      "label": "Resource ID Code"
    },
    {
      "field_name": "notes",
      "label": "Description",
      "form_snippet": "markdown.html",
      "form_placeholder": "eg. Some useful notes about the data"
    },
    {
      "field_name": "geographic_extent",
      "label": "Geographic extent"
    },
    {
      "field_name": "geographic_boudingbox",
      "label": "Geographic bounding box"
    },
    {
      "field_name": "minmax_height",
      "label": " Minimum and maximum height"
    },
      "field_name": "vertcal_date",
      "label": "Vertical Date"
      "preset": "date"
    },
      "field_name": "temporal_date_from",
      "label": "Temporal Date From"
      "preset": "date"
    },
      "field_name": "temporal_date_to",
      "label": "Temporal Date To"
      "preset": "date"
    },
    {
      "field_name": "topic",
      "label": "Topic",
      "help_text": "Which topic",
      "help_inline": true,
      "preset": "inlandWaters - sjöar och vattendrag",
      "form_placeholder": "eg. inlandWaters",
      "choices": [
        {
          "value": "farming - areella näringar",
          "label": {"en": "farming","sv": "areella näringar"}
        },
        {
          "value": "biota - biologi och ekologi",
          "label": {"en": "biota","sv": "biologi och ekologi"}
        },
        {
          "value": "boundaries - administrativa gränser",
          "label": {"en": ""boundaries","sv": "administrativa gränser"}
        },
        {
          "value": "climatologyMeteorologyAtmosphere - ?",
          "label": {"en": "climatologyMeteorologyAtmosphere","sv": "?"}
        },
        {
          "value": "economy - ekonomiska förhållanden",
          "label": {"en": "economy","sv": "ekonomiska förhållanden"}
        },
        {
          "value": "elevation - höjddata",
          "label": {"en": "elevation","sv": "höjddata"}
        },
        {
          "value": "environment - miljörisker, skydd, landskap",
          "label": {"en": "environment","sv": "miljörisker, skydd, landskap"}
        },
        {
          "value": "geoscientificInformation - geovetenskap",
          "label": {"en": "geoscientificInformation","sv": "geovetenskap"}
        },
        {
          "value": "health - hälsovård, human ekologi",
          "label": {"en": "health","sv": "hälsovård, human ekologi"}
        },
        {
          "value": "imageryBaseMapsEarthCover - baskartor",
          "label": {"en": "imageryBaseMapsEarthCover","sv": "baskartor"}
        },
        {
          "value": "intelligenceMilitary - försvar",
          "label": {"en": "intelligenceMilitary","sv": "försvar"}
        },
        {
          "value": "inlandWaters - sjöar och vattendrag",
          "label": {"en": "inlandWaters","sv": "sjöar och vattendrag"}
        },
        {
          "value": "oceans - kust och hav",
          "label": {"en": "oceans","sv": "kust och hav"}
        },
        {
          "value": "location - adresser, stomnät, ortnamn",
          "label": {"en": "location","sv": "adresser, stomnät, ortnamn"}
        },
        {
          "value": "planningCadastre - fysisk planering",
          "label": {"en": "planningCadastre","sv": "fysisk planering"}
        },
        {
          "value": "society - samhälle och kultur, demografi",
          "label": {"en": "society","sv": "samhälle och kultur, demografi"}
        },
        {
          "value": "structure - byggnader och konstruktioner",
          "label": {"en": "structure","sv": "byggnader och konstruktioner"}
        },
        {
          "value": "transportation - transportinfrastruktur",
          "label": {"en": "transportation","sv": "transportinfrastruktur"}
        },
        {
          "value": "utilitiesCommunication - tekniska nät",
          "label": {"en": "utilitiesCommunication","sv": "tekniska nät"}
        }
      ]
    },
    {
      "field_name": "summary",
      "label": "Summary / Abstract",
      "form_snippet": "markdown.html",
      "form_placeholder": "eg. Abstract or summary"
    },
    {
      "field_name": "sampleimage_url",
      "label": "Sample Image URL",
      "form_placeholder": "http://example.com/image.jpg",
      "display_snippet": "link.html"
    },
    {
      "field_name": "sampleimage_caption",
      "label": "Image description"
    },
    {
      "field_name": "sampleimage_format",
      "label": "Image format"
    },
    {
      "field_name": "tag_string",
      "label": "Keywords",
      "preset": "tag_string_autocomplete",
      "form_placeholder": "eg. "
    },
    {
      "field_name": "spatialrepresentation",
      "label": { "en": " Method for Spatial Representation", "se":" Metod för rumslig 

representation" },
      "help_text": "Which spatial method?",
      "help_inline": true,
      "preset": "vector",
      "form_placeholder": "eg. point of contact",
      "choices": [
        {
          "value": "vector",
          "label": "vector"
        },
        {
          "value": "grid - raster",
          "label": {"en": "grid","sv": "raster"}
        },
        {
          "value": "textTable - text eller tabell",
          "label": {"en": "text table","sv": "text eller tabell"}
        },
        {
          "value": "tin - TIN",
          "label": {"en": "tin","sv": "TIN"}
        },
        {
          "value": "stereoModel - stereomodell",
          "label": {"en": "stereo Model","sv": "stereomodell"}
        },
        {
          "value": "video",
          "label": "video"
        }
      ]
    },
    {
      "field_name": "scalefactor",
      "label": " Scale Factor"
    },
    {
      "field_name": "distance_btwn_obs",
      "label": "Distance between observations"
    },
    {
      "field_name": "type_of_service",
      "label": "Type of Service"
    },
    {
      "field_name": "Coupled_resource",
      "label": "Distance between observations"
    },
    {
      "field_name": "character_in_resource",
      "label": " Character in the resource"
    }
  ],
  "resource_fields": [
    {
      "field_name": "url",
      "label": "URL",
      "preset": "resource_url_upload"
    },
    {
      "field_name": "name",
      "label": "Name",
      "form_placeholder": "eg. January 2011 Gold Prices"
    },
    {
      "field_name": "guid",
      "label": "UUID",
    },
    {
      "field_name": "created_date",
      "label": "Created Date"
      "preset": "date"
    },
    {
      "field_name": "lastupdated_date",
      "label": "Last Updated Date"
      "preset": "date"
    },
    {
      "field_name": "description",
      "label": "Description",
      "form_snippet": "markdown.html",
      "form_placeholder": "Some useful notes about the data"
    },
    {
      "field_name": "format",
      "label": "MIMEType",
      "preset": "resource_format_autocomplete"
    },
    {
      "field_name": "format_version",
      "label": "Format Version"
    },
    {
      "field_name": "function",
      "label": "Function of File",
    },
    {
      "field_name": "size",
      "label": "File Size",
    },
    {
      "field_name": "checksum",
      "label": "File Checksum",
    },
    {
      "field_name": "checksum_type",
      "label": "File Checksum Type",
    }
  ]
}

Empty selectable field problem

Hi again,

I have been customizing a schema and I'm doing some tests. It seems that is working quite very well but I am having problems for a Selectable field: If there is no choice selected from a selectable field then the following value appears in the field (once I've created a new dataset).

Project-Id-Version: CKAN Report-Msgid-Bugs-To: EMAIL@ADDRESS POT-Creation-Date: 2015-01-26 11:55+0000 PO-Revision-Date: 2015-02-25 10:36+0000 Last-Translator: Adrià Mercader [email protected] Language-Team: Catalan (http://www.transifex.com/projects/p/ckan/language/ca/) Plural-Forms: nplurals=2; plural=(n != 1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 0.9.6

My dataset configuration is below:

{
  "field_name": "city_integration",
  "label": "Integration",
  "help_text": "Is integrated in City DB?",
  "help_inline": true,
  "preset": "select",
  "choices": [
    {
      "value": "yes",
      "label": "Yes"
    },
    {
      "value": "no",
      "label": "No"
    }
  ]
}

And preset configuration is below:

{
  "preset_name": "select",
  "values": {
    "form_snippet": "select.html",
    "display_snippet": "select.html",
    "validators": "scheming_required scheming_choices"
  }
}

What I've made it wrong? May do I should to change the "validators" specified on the preset?

I would appreciate any advice.

Thanks.

Encoding error when adding non-ascii characters in schema

The schema should be able to accept non-ascii utf-8 encoded character since we can add the description/label of the field. JSON is supposed to be always utf-8.

However, adding non-ascii chars (for example 'é') results in an error when loading the schema file.

The follow configuration item

        {
            "field_name": "update_frequency",
            "label": "Frequence de mise à jour",
            "form_snippet": "update_frequency_qc.html"
        },

Gives following error

Module ckanext.scheming.helpers:29 in scheming_language_text          view
>>  return t.decode('utf-8')
Module encodings.utf_8:16 in decode          view
>>  return codecs.utf_8_decode(input, errors, True)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe0' in position 18: ordinal not in range(128)

Full error logs http://pastebin.com/piGmWhqF

500 Server Error -- repeated posts to Solr when creating custom dataset

Hi,

I'm hitting a 500 Server error when trying to create an instance of my custom dataset.

Configuration

  • CKAN v 2.4.1
  • ckanext-scheming @969995b
  • My schema

Steps to reproduce

  • Create a fresh CKAN instance with ckanext-scheming
  • Visit the form to create the new dataset (i.e., http://192.168.99.100/beataml_patient/new)
  • Fill out the form, get to the next page to add resources, click next...
  • 💥
  • Visiting http://192.168.99.100/beataml_patient/test-patient shows that it's a "DRAFT".
  • Clicking "Modify" takes me back to the same "new" form.
  • Rinse, repeat.

Solr logs

I see that there are calls being made to Solr which could be from process_solr.

solr_1       | 1021391 [qtp1894627749-17] INFO  org.apache.solr.core.SolrCore  – [ckan] webapp=/solr path=/select params={q=name:"test-patient"+OR+id:"test-patient"&wt=json&fq=site_id:"default"&rows=1} hits=1 status=0 QTime=0
solr_1       | 1021401 [qtp1894627749-15] INFO  org.apache.solr.core.SolrCore  – [ckan] webapp=/solr path=/select params={q=name:"test-patient"+OR+id:"test-patient"&wt=json&fq=site_id:"default"&rows=1} hits=1 status=0 QTime=1
solr_1       | 1021409 [qtp1894627749-14] INFO  org.apache.solr.core.SolrCore  – [ckan] webapp=/solr path=/select params={q=name:"test-patient"+OR+id:"test-patient"&wt=json&fq=site_id:"default"&rows=1} hits=1 status=0 QTime=0
etc...

There's nothing being generated in CKAN logs.

Do you have any thoughts as to what could be causing this?

Thanks!

500 Internal Server Error

After installing and enabling the extension, CKAN stops loading and throws a 500 Internal Server Error.

Steps to produce:
Install CKAN 2.3 from package
Clone this repo and then python setup.py install
Install requirements pip install -r requirements.txt
Add "scheming_datasets" to ckan.plugins
Add "scheming.dataset_schemas = ckanext.scheming:ckan_dataset.json"

Below is the error from the webserver:

mod_wsgi (pid=29654): Target WSGI script '/etc/ckan/default/apache.wsgi' cannot be loaded as Python module.
mod_wsgi (pid=29654): Exception occurred processing WSGI script '/etc/ckan/default/apache.wsgi'.
Traceback (most recent call last):
File "/etc/ckan/default/apache.wsgi", line 10, in
application = loadapp('config:%s' % config_filepath)
File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
return loadobj(APP, uri, name=name, *_kw)
File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj
return context.create()
File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 710, in create
return self.object_type.invoke(self)
File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 146, in invoke
return fix_call(context.object, context.global_conf, *_context.local_conf)
File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/deploy/util.py", line 56, in fix_call
val = callable(_args, *_kw)
File "/usr/lib/ckan/default/src/ckan/ckan/config/middleware.py", line 57, in make_app
load_environment(conf, app_conf)
File "/usr/lib/ckan/default/src/ckan/ckan/config/environment.py", line 232, in load_environment
p.load_all(config)
File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 134, in load_all
load(*plugins)
File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 149, in load
service = _get_service(plugin)
File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 255, in _get_service
return plugin.load()(name=plugin_name)
File "/usr/lib/ckan/default/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg/pkg_resources.py", line 1989, in load
entry = import(self.module_name, globals(),globals(), ['name'])
File "/usr/lib/ckan/default/lib/python2.7/site-packages/ckanext_scheming-0.0.1-py2.7.egg/ckanext/scheming/plugins.py", line 6, in
from ckan.plugins.toolkit import (get_validator, get_converter,
ImportError: cannot import name get_validator

Any help/ direction would be much appreciated,

Julian

Error when I enable the extension 'ckanext-scheming'

Hi Ian.

I have developed some opendata portals in Spain (e.g. https://datos.upo.gob.es) which use CKAN as a backend with Wordpress + Wijmo as a frontend. I have a portal that needs multilingual support and I have solved this problem by adding extra fields in the dataset form following the CKAN extension docs, but I would like to try out your ckanext-fluent extension.

I have installed ckanext-scheming, but when I activate the plugin and I access the server CKAN shows the following error:

File "/usr/lib/ckan/default/src/ckanext-scheming/ckanext/scheming/plugins.py", line 6, in 
   from ckan.plugins.toolkit import (get_validator, get_converter,
ImportError: cannot import name get_validator

What am I doing wrong?

How to implement tag-like autocomplete for large select choice lists?

Using the select widget with its choices defined in the custom schema becomes a performance issue for large lists of choices, as they are fully loaded when the dataset edit form is rendered. E.g., 2000 lines of geojson for the spatial snippet will significantly slow down the read view.

@wardi could you point me in the right direction: Is there an elegant way to provide an autocompleting box (like the tag snippet) for custom lists of label:value pairs?

Feature request: date preset

This is a very useful plugin, thanks for creating it in the first place! How much hassle would it be to create a date preset with some shiny js date picker?

Updating a dataset fails with missing organization if not "show_organizations_selector"

Maybe I'm doing something wrong on my end, apologies if that's the case.
It appears that the hidden organization input is missing from the package form.

Symptoms: admins and editors of organizations cannot update datasets of their own organization if they did not create them themselves, resulting in

The form contains invalid entries:

Owner org: A organization must be supplied

The organization snippet follows
ckan's snippet, and when this bug happens, the template's state is:

  • dataset_has_organization: fe234287-6219-4335-b6d9-4cad894eef44 (so we have an org)
  • group id: none! therefore, the hidden input that should preserve the group id is not shown, so there's no organization/group_id in the form, hence the error.
  • owner org: fe234287-6219-4335-b6d9-4cad894eef44

Modifying the organization snippet gives me two options:

  • "if not show_organizations_selector", including a hidden input with name "owner_org" and the owner_org id (== what the organizations selector provides after all the js magic, or did I go wrong there?) does nothing, still getting "missing owner_org" error.
  • disabling the "if show_organizations_selector" if -clause, and therefore always showing the org input (actually good to give the editors control over moving datasets between their respective orgs, different story though) - works. of course this goes against ckan's existing permissions handling.

I'd assume any production instance running ckanext-scheming, where organization admins/editors update datasets they didn't create themselves, will soon run into the same problem - if it's not something on my end. Also there's a typo in the error message, and it could contain more info, e.g. show_organizations_selector et al. would be useful.

Tag vocabularies

Scheming currently does not handle using tag vocabularies in schemas. I am aware that choices targets selection from a given list. However, using tag vocabs for that purpose would allow creating, deleting and modifying the possible values programmatically via the remote API. This is very useful for uses-cases where scheming is used to create and maintain a number of different interfaces for different user-groups and where the list of potential choices for different fields might change frequently (e.g. due to user feedback).

Here is an implementation: #116

Display snippet for external link

Since display snippet link.html seems to link back to the dataset page, it would be nice to have a display snippet that simply renders the field content as a link.

So instead of

{{ h.link_to(data[field.field_name], rel=field.display_property, target='_blank') }}

this:

{{ h.link_to(data[field.field_name], rel=data[field.field_name], target='_blank') }}

does that make sense?

dataset schemas

Please, what must be included in ckanext.spatialx:spatialx_schema.json, ckanext.spatialx:spatialxy_schema.json?

When displaying additionnal info, should use the value and not the id

Sometimes, the data provided for scheming is a list with the form (id, value), mainly in the case of a value list.

For example, to declare an update frequency, one has to provide a standardized value (eg. freq:irregular), but we want to display something more fitted for human (e.g "Ponctuel").

Given how things are working it is far from straighforward. Since the place where it is the main concerns is when not using english, at least the display should use the translation feature.

Pagination for organization broken

The pagination for organizations relies on an undocumented method on IGroupForm (see ckan/ckan#2771). Because this method (group_controller()) does not exist on SchemingOrganizationsPlugin, it falls back to the group controller.

This leads to the generation of links in the pagination like this /group/org-name?page=2.

PR follows.

Feature request: spatial widget

Ok this is stretching it a bit, but since scheming tackles custom form widgets, and ckanext-spatial provides this really good to have but (for end users) quite challenging spatial field, it would be very useful to integrate both.

A form_snippet spatial.html should allow users to

  • paste a valid GeoJSON geometry as per ckanext-spatial, or
  • draw a polygon on a leaflet map, writing back the geojson geometry of the convex hull (if several polygons are drawn) or
  • upload a geojson file with the bounding polygon (or a bunch of features), then save the convex hull's geometry

A display_snippet spatial.html could render the dataset extent just like ckanext-spatial does as a map, hiding the unhelpful WKT blurb. Edit: done
image

Also posted to ckanext-spatial.

scheming_required apply the not_missing validator instead of the not_empty one

When I set "required" : "true" and as my first validator : "scheming_required", nothing happened because the validator not_missing is present here instead of not_empty :

@scheming_validator
def scheming_required(field):
"""
not_empty if field['required'] else ignore_missing
"""
if field.get('required'):
return not_missing
return ignore_missing

Notes fields being duplicated

Running Ckan 2.3.1

Attempting to update to scheming release-1.0.0, however I am seeing my description field being duplicated below tags.

The issue (for me) appears after this commit 8e83c0e

If I revert to the previous commit e4941f5 the duplication goes away.

e4941f5
scheming error 1

8e83c0e
scheming error 2

Can't set "license_id" & "organization" required

In many cases organization and license should be mandatory.

However, adding "required": true does not seem to be effective. Although it is possible to add a validator not_empty, it does not add the "required" red star next to the field.

Built-in date preset results in unix timestamps when combined with plain-text solr fields.

An input string of "2014-03-27" being loaded into a plain-text solr field (type="string" or type="text" in the schema) will result in a plain-text string containing the unix timestamp of "2014-3-27" instead of a plain-text string containing "2014-03-27".

This only occurs when using the built-in date preset. Removing the preset results in "2014-03-27" being stored.

Losing field data with validation

We are currently encountering a situation where when we enable validation on
either a multiple_select or multiple_checkbox type we will lose data if we enter
more than one option at a time.

If we remove validation from these fields they appear to behave normally.
Any tips you can provide, were only interested at present in ensuring the fields
are required using multiple choices

{
"field_name": "langcheck",
"label": "Language Checkbox",
"preset": "multiple_checkbox",
"required": true ,
"validators": "scheming_required",
"choices": [
{"value": "en-CA [default]", "label": "English (Canadian)"},
{"value": "fr-CA", "label": "French (Canadian)"}
]
},
{
"field_name": "langselect",
"label": "Language Select",
"preset": "multiple_select",
"required": true ,
"validators": "scheming_required",
"choices": [
{"value": "en-CA [default]", "label": "English (Canadian)"},
{"value": "fr-CA", "label": "French (Canadian)"}
]
},

Document / make easier to run the tests locally

The ini files are located on the tests folder, which is fine but not where generally extensions have them, so worth mentioning on the README.
The use = config:../../../links/ckan/test-core.ini has a links folder not present on a default set up, I guess this is set for Travis?
There are two ini files, what's test_subclass.ini for?

Changing /dataset link

What are steps are needed to switch links from the default schema to a new schema?
Is it just a matter of changing a few templates to link "/catalog", instead of "/dataset"?

Global helper h not available in macros

As the title says, I can't get to h. e.g.,

{% set map_config = h.get_common_map_config() %}

will throw server errors. Would anyone know a simple fix?

Edit: not available in macros. Templates are fine.

Selecting Schemas for a New Dataset

Hi,

Does anybody know how do I should to get a button of "Add new dataset" in the main window for each schema that I have defined? Is that something implemented in this extension?

I have been following the documentation and the examples but I am a bit stuck right now.

Thanks,

Jordi.

Feature request: ability to specify additional CKAN User fields

It would be nice to add additional fields to the user profile, e.g. twitter, github, API keys to 3rd-party services, etc.

I imagine these additional fields can be used by CKAN extensions to implement additional functionality - e.g. tweeting when a dataset is updated using the user's twitter account, rendering a CartoDB viz using their CartoDB account, etc.

'dict object' has no attribute

I have an error when opening a dataset generated by a harvester: ckan complains that the author_email is missing.

Seems that it's ckanext-scheming that triggers the error.

See error trail: http://pastebin.com/Ssneu6sP

The harvester used is the ckanext-dcat used to harvest a DCAT-RDF file coming build using the following example: https://github.com/ckan/ckanext-dcat/blob/master/examples/catalog_datasets_list.rdf

When the harvester creates the datasets, it does not provide/create a author_email field. If I edit a dataset and resave it (without changing anything), the field is created and the error does not appear anymore.

Here is an API output for 2 dataset generated by the harvester: the first one has author_email (it has been edited/saved) while the second is directly how produced by the harvester

http://pastebin.com/Vt78AgmX

Search over all the fields

If the CKAN search should "know" about all the defined fields of a schema, this extensions should make use of the before_index method and customize the dict that gets sent to Solr.

This issue is probably related to #54.

Best way to hide a field in the Additional table

I know this is not supported, but what would be the best way to define on your schema that you don't want a field to be displayed on the Additional Info table?

This check led me to try something like:

    {     
      "field_name": "private",    
      "label": "Visibility",    
      "required": true,    
      "validators": "boolean_validator datasets_with_no_organization_cannot_be_private opendatani_private_datasets",
      "form_snippet": "visibility_form_field.html",
      "display_snippet": null
    },

But it had no effect.

Arguably the private dataset should be one of the ones excluded, but I'm thinking more about a generic option.

What do you think about "display_snippet": null or a new explicit "display": false key?

Group/organization form seem not to work

The scheming for datasets works like a charm, but for groups and organization only the about page seems to be changed. I can save additional fields via the API, but the form to add or edit a group/organization do not show the fields defined in the schema.

How does that work?

organisation field doesn't show selected organisation text

Hi I'm using ckan 2.4 just trying to display the ckan_dataset schema provided in the package.

When I go to select an organisation from the drop down (or there an organisation already selected as I have started making a dataset within the organisation) the selected organisation doesn't show up in the box. It is definitely selected, as can be seen in the developer tools (where the selected option updates) and the dataset can be create and shows up under the correct organisation. But the text just isn't showing up, it just remains blank.

Thanks,
Renee

Add schema field in search

Is there a specific need to add a schemed field in the search feature of CKAN?

I've added a field that I need searchable:

        {
            "field_name": "featured_dataset",
            "label": "Jeu de données vedette",
            "preset": "multiple_checkbox",
            "choices": [
                {
                    "label": "Oui",
                    "value": "is_featured"
                }
            ],
            "help_text": "Affiche le jeu de données sur la page d'accueil"
        }

I've update the solr schema.xml:

    <field name="tags" type="string" indexed="true" stored="true" multiValued="true"/>
    <field name="groups" type="string" indexed="true" stored="true" multiValued="true"/>
    <field name="featured_dataset" type="string" indexed="true" stored="true" multiValued="true"/>

    <field name="capacity" type="string" indexed="true" stored="true" multiValued="false"/>

Then reloaded everything.

I'm no SOLR expert, but I would expect a search query like q=featured_dataset:is_featured to work, but it does not. q=is_featured works, but clearly it's not specific enough.

Create a scheming registry

And maybe, making it a bit meta - using CKAN to catalog scheming schemas created by the community :)

Since you can specify URLs when defining schemas, maybe even enforce a convention (using scheming?) to point to different versions of a schema.

Format date display and form field to hide time

CKAN saves datetimes, but the jquery-ui datepicker shows only dates and will be blank if set to a datetime. This causes a dataset with date fields to lose their value when updating.

The new date preset should format CKAN's datetime to dates only, so the datepicker won't lose the value, and the date field is, as the name says, just a date field.

Licence id: have the first list selected by default

For the organization field, the first organization is selected by default which mean that except if the user specifically select "no organization", there is always a default.

For licence, it should work the same, at least if the fields is set to "required" as it work for other select fields. (Maybe this will be resolved if #48 is resolved?)

Custom organisation schemas and ckanext-hierarchy

ckanext-hierarchy instantiates the view singleton for organisations, and so does scheming, so there can only be one. Is there a way to have both, apart from implementing hierarchy as part of scheming?

Custom fields do not get updated when editing a resource

I have some trouble trying to edit a resource which has custom fields. For instance, I have a custom field using : "preset": "multiple_choice" with 2 choices. During the creation of the resource I selected both checkbox so I got the two values in the additional information box.
Then I tried to edit it by deselecting them, but these two values didn't change in the additional information box, because in the dictionnary (api/3/action/package_show?id=....) values was unchanged.
And this is true for all additional fields.

So I was wondering if you had already had this kind of behavior?

Support list of dicts

I want to accept arbitrary dicts for a field that i defined in a scheme. It seems that CKAN tries to apply some kind of sub-schema if it encounters a list of dicts. Is it possible to define such sub-schemas with this extension?
And if the fields are not known, all the data is put into the key "__junk" as a flattened dict.

What I ended up doing is writing my own validator that gets the values out of the __junk, but I'm pretty sure this is a bad solution (see here for details: https://github.com/ogdch/ckanext-switzerland/blob/421de6c546462f0ac5764f93064d68d285addda2/ckanext/switzerland/validators.py#L39-L62).

Any ideas how to handle this?

Feature request: retain extra fields

Not sure whether this is a bug or a feature, but it seems that enabling ckanext-scheming with a custom schema will, on first saving a dataset with the new schema, delete any existing "extra" fields. Even to only retain the existing extra fields to safely migrate data would be helpful - this could be achieved if config settings would toggle the display of existing extra fields and/or form fields.

Date fields do not work with resources

Filling date fields for resources results in StatementError: datetime.datetime(2017, 1, 1, 0, 0) is not JSON serializable when trying to save a non-null value. Date fields work fine for datasets.

Below is a schema for verifying this behavior. Create a dataset and a resource without filling the date fields first, then edit the resource and fill the date fields to reproduce the error.

{
  "scheming_version": 1,
  "dataset_type": "dataset",
  "about": "A reimplementation of the default CKAN dataset schema",
  "about_url": "http://github.com/open-data/ckanext-scheming",
  "dataset_fields": [
    {
      "field_name": "title",
      "label": "Title",
      "preset": "title",
      "form_placeholder": "eg. A descriptive title"
    },
    {
      "field_name": "name",
      "label": "URL",
      "preset": "dataset_slug",
      "form_placeholder": "eg. my-dataset"
    },
    {
      "field_name": "notes",
      "label": "Description",
      "form_snippet": "markdown.html",
      "form_placeholder": "eg. A detailed description"
    },
    {
      "field_name": "tag_string",
      "label": "Tags",
      "preset": "tag_string_autocomplete",
      "form_placeholder": "eg. economy, mental health, government"
    },
    {
      "field_name": "owner_org",
      "label": "Organization",
      "preset": "dataset_organization"
    }
  ],
  "resource_fields": [
    {
      "field_name": "url",
      "label": "URL",
      "preset": "resource_url_upload"
    },
    {
      "field_name": "name",
      "label": "Name"
    },
    {
      "field_name": "description",
      "label": "Description",
      "form_snippet": "markdown.html",
      "form_placeholder": "eg. A detailed description"
    },
    {
      "field_name": "validSince",
      "label": "Valid since",
      "preset": "date"
    },
    {
      "field_name": "validUntil",
      "label": "Valid until",
      "preset": "date"
    },
    {
      "field_name": "format",
      "label": "Format",
      "preset": "resource_format_autocomplete"
    }
  ]
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.