diff --git a/changes/232.canada.feature b/changes/232.canada.feature new file mode 100644 index 00000000000..a2a1cfa2be9 --- /dev/null +++ b/changes/232.canada.feature @@ -0,0 +1 @@ +Added a `create_atom_id` implement method to the `IFeed` implement class. This allows for plugins to customize the generation of Atom entry IDs. diff --git a/ckan/plugins/interfaces.py b/ckan/plugins/interfaces.py index b36660ec90e..053e34731a9 100644 --- a/ckan/plugins/interfaces.py +++ b/ckan/plugins/interfaces.py @@ -206,6 +206,13 @@ def get_item_additional_fields( """ return {} + # (canada fork only): add feed id gen implement method + # TODO: upstream contrib!! + def create_atom_id(self, atom_id: str, resource_path: str, + authority_name: Optional[str] = None, + date_string: Optional[str] = None) -> str: + pass + class IResourceUrlChange(Interface): u''' diff --git a/ckan/views/feed.py b/ckan/views/feed.py index cb1d154a2df..e245e0e3fb2 100644 --- a/ckan/views/feed.py +++ b/ckan/views/feed.py @@ -836,8 +836,16 @@ def _create_atom_id(resource_path: str, return u''.join([site_url, resource_path]) tagging_entity = u','.join([authority_name, date_string]) - return u':'.join(['tag', tagging_entity, resource_path]) + # (canada fork only): add feed id gen implement method + # TODO: upstream contrib!! + atom_id = ':'.join(['tag', tagging_entity, resource_path]) + for plugin in plugins.PluginImplementations(plugins.IFeed): + if hasattr(plugin, 'create_atom_id'): + atom_id = plugin.create_atom_id( + atom_id, resource_path, authority_name, date_string) + + return atom_id # Routing # (canada fork only): custom single dataset feed