diff --git a/changes/1534.feature b/changes/1534.feature new file mode 100644 index 000000000..cac3c34dc --- /dev/null +++ b/changes/1534.feature @@ -0,0 +1 @@ +Added Dataset & Resource repeating Relationship field groups. diff --git a/ckanext/canada/plugins.py b/ckanext/canada/plugins.py index 741b4b853..fd2abe920 100755 --- a/ckanext/canada/plugins.py +++ b/ckanext/canada/plugins.py @@ -407,6 +407,11 @@ def before_index(self, data_dict): for cr in data_dict['credit']: cr.pop('__extras', None) + if data_dict.get('relationship'): + related_relationships = [rel['related_relationship'] for rel in data_dict['relationship']] + related_types = [rel['related_type'] for rel in data_dict['relationship']] + data_dict.pop('relationship', None) + return data_dict # IDataDictionaryForm @@ -831,8 +836,6 @@ def get_validators(self): validators.protect_portal_release_date, 'canada_copy_from_org_name': validators.canada_copy_from_org_name, - 'canada_non_related_required': - validators.canada_non_related_required, 'canada_maintainer_email_default': validators.canada_maintainer_email_default, 'user_read_only': diff --git a/ckanext/canada/schemas/dataset.yaml b/ckanext/canada/schemas/dataset.yaml index 1f278bb8a..6d48fdf62 100644 --- a/ckanext/canada/schemas/dataset.yaml +++ b/ckanext/canada/schemas/dataset.yaml @@ -453,6 +453,7 @@ dataset_fields: en: FGP viewer is supported value: fgp_viewer +- preset: canada_dataset_relationship # @@ -462,16 +463,17 @@ resource_fields: - preset: canada_resource_unique_identifier - preset: canada_resource_name -- preset: canada_resource_related_relationship -- preset: canada_resource_related_type +- preset: canada_resource_relationship - preset: canada_resource_date_published - preset: canada_resource_type form_restrict_choices_to: - application - api + - data_dictionary - dataset - guide - faq + - schema - specification - terminology - tool @@ -497,3 +499,7 @@ resource_fields: preset: hidden_in_form display_snippet: validation_timestamp.html form_panel: validation + +# LEGACY FIELDS +- preset: _legacy_canada_related_type +- preset: _legacy_canada_related_relationship diff --git a/ckanext/canada/schemas/info.yaml b/ckanext/canada/schemas/info.yaml index e5fcce004..927899cd9 100644 --- a/ckanext/canada/schemas/info.yaml +++ b/ckanext/canada/schemas/info.yaml @@ -146,6 +146,9 @@ dataset_fields: error_snippet: fluent_text.html validators: fluent_text output_validators: fluent_text_output + form_attrs: + size: 100 + class: form-control # Field = Keywords English. # {Commonly used words or phrases which describe the asset, in English} @@ -387,6 +390,8 @@ dataset_fields: en: The beginning/ending date(s) of publication and/or sequential designations used on items in a series, in French fr: Dates de début/fin de la publication et/ou de désignation séquentielle utilisées pour les articles d’une série, en français preset: fluent_text + form_attrs: + class: form-control # Field = Homepage English. # {A program or homepage that can be navigated to gain additional or contextual information about the asset.} @@ -488,6 +493,8 @@ dataset_fields: # {The date the asset may be published on the Portal (YYYY-MM-DD)} - preset: canada_portal_release_date +- preset: canada_dataset_relationship + # # RESOURCE FIELDS @@ -504,8 +511,7 @@ resource_fields: # {A French name given to the resource} - preset: canada_resource_name -- preset: canada_resource_related_relationship -- preset: canada_resource_related_type +- preset: canada_resource_relationship # Field = Date Published. # Add a Calendar control to select a Date. @@ -545,3 +551,7 @@ resource_fields: # Field = Location. # {The location for online access to the distribution of the resource, if the file resides elsewhere.} - preset: canada_resource_url + +# LEGACY FIELDS +- preset: _legacy_canada_related_type +- preset: _legacy_canada_related_relationship diff --git a/ckanext/canada/schemas/presets.yaml b/ckanext/canada/schemas/presets.yaml index 71d2a069e..008a84980 100644 --- a/ckanext/canada/schemas/presets.yaml +++ b/ckanext/canada/schemas/presets.yaml @@ -2689,9 +2689,7 @@ presets: class: form-control # Field = Relationship Type. -# List box Source: Relationship Type code table (refer to Data Migration). -# {The Related Record’s relationship with the dataset} -- preset_name: canada_resource_related_relationship +- preset_name: canada_dataset_related_relationship values: field_name: related_relationship label: @@ -2700,7 +2698,6 @@ presets: help_text: en: The Related Record’s relationship with the dataset fr: Relation du dossier connexe avec le jeu de données - form_panel: related choices: - label: en: Continues @@ -2755,25 +2752,64 @@ presets: fr: Séparé de value: separated_from - label: - en: Split into ... - fr: Divisé en … + en: Split into + fr: Divisé en value: split_into - label: - en: Merged with ... + en: Merged with fr: Fusionné avec value: merged_into - label: en: Changed back to fr: Restauré à value: changed_back_to + form_include_blank_choice: true form_snippet: select.html display_snippet: select.html validators: scheming_required scheming_choices + required: true + form_panel: relationships + +# Field = Related Record URL. +- preset_name: canada_dataset_related_url + values: + field_name: related_url_translated + label: + en: Related Record URL + fr: FR Related Record URL FR + help_text: + en: The URL for online access to the related record + fr: FR The URL for online access to the related record FR + fluent_form_label: + en: + en: "Related Record URL (English)" + fr: "FR Related Record URL (anglais) FR" + fr: + en: "Related Record URL (French)" + fr: "FR Related Record URL (français) FR" + fluent_help_text: + en: + en: The URL for online access to the related record + fr: FR The URL for online access to the related record FR + fr: + en: The URL for online access to the related record + fr: FR The URL for online access to the related record FR + # copied from fluent_text preset + form_snippet: fluent_text.html + display_snippet: fluent_link.html + display_attributes: + style: "word-wrap: break-word" + error_snippet: fluent_text.html + validators: fluent_text + output_validators: fluent_text_output + required: true + form_panel: relationships + form_attrs: + style: "width: 100%;" + class: form-control # Field = Record Type. -# List box Source: Record Type code table (refer to Data Migration). -# {The portal or page to which the Related Record belongs} -- preset_name: canada_resource_related_type +- preset_name: canada_dataset_related_type values: field_name: related_type label: @@ -2782,9 +2818,6 @@ presets: help_text: en: The portal or page to which the Related Record belongs fr: Portail auquel appartient le dossier connexe - form_panel: related - required: true - form_include_blank_choice: true choices: - label: en: Open Data @@ -2802,11 +2835,45 @@ presets: en: Other fr: Autre value: other + required: true + form_include_blank_choice: true + form_snippet: select.html + display_snippet: select.html + validators: scheming_required scheming_choices + form_panel: relationships + +- preset_name: canada_resource_related_relationship + values: + field_name: related_relationship + label: + en: Relationship Type + fr: Type de relation + help_text: + en: The Related Record’s relationship with the resource + fr: Relation du dossier connexe avec le jeu de données + choices: + - label: + en: Defines + fr: FR Defines FR + value: defines + - label: + en: Defined by + fr: FR Defined par FR + value: defined_by + - label: + en: References + fr: FR References FR + value: references + - label: + en: Referenced by + fr: FR Referenced par FR + value: referenced_by + form_include_blank_choice: true form_snippet: select.html display_snippet: select.html - # no 'scheming_required' in validators because this field may be omitted - # for non-related-item resources - validators: ignore_missing scheming_choices + validators: scheming_required scheming_choices + required: true + form_panel: relationships # Field = Date Published. # Add a Calendar control to select a Date. @@ -2841,7 +2908,7 @@ presets: field_name: resource_type form_snippet: select.html display_snippet: select.html - validators: canada_non_related_required canada_static_rtype_tabledesigner scheming_choices + validators: scheming_required canada_static_rtype_tabledesigner scheming_choices required: true form_include_blank_choice: true form_panel: resource @@ -2978,6 +3045,10 @@ presets: en: Correspondence - Memorandum fr: Correspondance - note de service value: memorandum + - label: + en: Data Dictionary + fr: Dictionnaire de données + value: data_dictionary - label: en: Dataset fr: Jeu de données @@ -3190,6 +3261,10 @@ presets: en: Routing Slip fr: Bordereau d’acheminement value: routing_slip + - label: + en: Schema + fr: Schéma + value: schema - label: en: Social Media Resource - Blog Entry fr: Ressources des médias sociaux - entrée de blogue @@ -3267,7 +3342,7 @@ presets: form_placeholder: en: "eg. CSV, XML or JSON" fr: "par exemple CSV, XML ou JSON" - validators: canada_guess_resource_format scheming_required unicode_safe canada_non_related_required scheming_choices + validators: canada_guess_resource_format scheming_required unicode_safe scheming_required scheming_choices required: false form_include_blank_choice: true form_panel: resource @@ -4065,17 +4140,6 @@ presets: upload_field: upload upload_clear: clear_upload -# XXX This is a copy of the resource URL field to be displayed only in the -# related item panel but is not used directly in any schemas -- preset_name: _canada_related_resource_url - values: - field_name: url - label: - en: Record URL - help_text: - en: The URL for online access to the related record - required: true - # Field = Data Includes URI. # Default Value = Unchecked. # {The most important data items in this resource have a URI, e.g. data in RDF format.} @@ -4124,3 +4188,63 @@ presets: display_snippet: null validators: ignore output_validators: canada_output_none + + +- preset_name: canada_dataset_relationship + values: + field_name: relationship + form_panel: relationships + label: + en: Relationship + fr: FR Relationship FR + display_snippet: dataset_relationship.html + form_blanks: 0 + + repeating_subfields: + + - preset: canada_dataset_related_relationship + - preset: canada_dataset_related_type + - preset: canada_dataset_related_url + + +- preset_name: canada_resource_relationship + values: + field_name: relationship + form_panel: relationships + label: + en: Relationship + fr: FR Relationship FR + display_snippet: resource_relationship.html + form_blanks: 0 + + repeating_subfields: + + - preset: canada_resource_related_relationship + - preset: canada_resource_type + - preset: canada_dataset_related_url + + +### +# LEGACY FIELDS +### + +- preset_name: _legacy_canada_related_type + values: + field_name: related_type + form_snippet: null + display_snippet: null + required: false + validators: ignore + form_panel: _exclude_from_form + output_validators: canada_output_none + +- preset_name: _legacy_canada_related_relationship + values: + field_name: related_relationship + form_snippet: null + display_snippet: null + required: false + validators: ignore + required: true + form_panel: _exclude_from_form + output_validators: canada_output_none diff --git a/ckanext/canada/templates/package/read.html b/ckanext/canada/templates/package/read.html index 33a04c582..714ab350b 100755 --- a/ckanext/canada/templates/package/read.html +++ b/ckanext/canada/templates/package/read.html @@ -179,27 +179,15 @@