From faa42092bfacdc46275836d7711a77f46424e656 Mon Sep 17 00:00:00 2001 From: Tim Sherratt Date: Wed, 16 Feb 2022 09:33:25 +1100 Subject: [PATCH] Fix for #1. Also some cleaning up of docs. --- api.ipynb | 253 ++++------------------------------ docs/api.html | 279 +++++--------------------------------- omeka_s_tools/__init__.py | 2 +- omeka_s_tools/api.py | 2 +- settings.ini | 2 +- 5 files changed, 63 insertions(+), 475 deletions(-) diff --git a/api.ipynb b/api.ipynb index f8ed20f..632204a 100644 --- a/api.ipynb +++ b/api.ipynb @@ -343,7 +343,7 @@ " if class_id:\n", " payload['o:resource_class'] = self.format_resource_id(class_id, 'resource_classes')\n", " if item_set_id:\n", - " payload['o:item_set'] = self.format_resource_id(template_id, 'item_sets')\n", + " payload['o:item_set'] = self.format_resource_id(item_set_id, 'item_sets')\n", " if media_files:\n", " files = self.add_media_to_payload(payload, media_files)\n", " response = self.s.post(f'{self.api_url}/items', files=files, params=self.params)\n", @@ -1306,229 +1306,6 @@ ")" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "template_payload = omeka.prepare_template_payload('templates/Person.json')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'@context': 'https://timsherratt.org/collections/api-context',\n", - " '@id': 'https://timsherratt.org/collections/api/resource_templates/9',\n", - " '@type': 'o:ResourceTemplate',\n", - " 'o:id': 9,\n", - " 'o:label': 'Person',\n", - " 'o:owner': {'@id': 'https://timsherratt.org/collections/api/users/1',\n", - " 'o:id': 1},\n", - " 'o:resource_class': {'@id': 'https://timsherratt.org/collections/api/resource_classes/492',\n", - " 'o:id': 492},\n", - " 'o:title_property': {'@id': 'https://timsherratt.org/collections/api/properties/1116',\n", - " 'o:id': 1116},\n", - " 'o:description_property': {'@id': 'https://timsherratt.org/collections/api/properties/528',\n", - " 'o:id': 528},\n", - " 'o:resource_template_property': [{'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/1116',\n", - " 'o:id': 1116},\n", - " 'o:alternate_label': None,\n", - " 'o:alternate_comment': None,\n", - " 'o:data_type': ['literal'],\n", - " 'o:is_required': True,\n", - " 'o:is_private': False},\n", - " {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/1199',\n", - " 'o:id': 1199},\n", - " 'o:alternate_label': None,\n", - " 'o:alternate_comment': None,\n", - " 'o:data_type': ['uri'],\n", - " 'o:is_required': False,\n", - " 'o:is_private': False},\n", - " {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/528',\n", - " 'o:id': 528},\n", - " 'o:alternate_label': None,\n", - " 'o:alternate_comment': None,\n", - " 'o:data_type': ['literal'],\n", - " 'o:is_required': False,\n", - " 'o:is_private': False},\n", - " {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/417',\n", - " 'o:id': 417},\n", - " 'o:alternate_label': None,\n", - " 'o:alternate_comment': None,\n", - " 'o:data_type': [],\n", - " 'o:is_required': False,\n", - " 'o:is_private': False},\n", - " {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/1144',\n", - " 'o:id': 1144},\n", - " 'o:alternate_label': None,\n", - " 'o:alternate_comment': None,\n", - " 'o:data_type': [],\n", - " 'o:is_required': False,\n", - " 'o:is_private': False},\n", - " {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/282',\n", - " 'o:id': 282},\n", - " 'o:alternate_label': None,\n", - " 'o:alternate_comment': None,\n", - " 'o:data_type': ['literal'],\n", - " 'o:is_required': False,\n", - " 'o:is_private': False},\n", - " {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/1357',\n", - " 'o:id': 1357},\n", - " 'o:alternate_label': None,\n", - " 'o:alternate_comment': None,\n", - " 'o:data_type': ['numeric:timestamp', 'literal'],\n", - " 'o:is_required': False,\n", - " 'o:is_private': False},\n", - " {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/1464',\n", - " 'o:id': 1464},\n", - " 'o:alternate_label': None,\n", - " 'o:alternate_comment': None,\n", - " 'o:data_type': ['customvocab:1'],\n", - " 'o:is_required': False,\n", - " 'o:is_private': False},\n", - " {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/1042',\n", - " 'o:id': 1042},\n", - " 'o:alternate_label': None,\n", - " 'o:alternate_comment': 'Place|Heritage place|State|Country',\n", - " 'o:data_type': ['resource:item', 'uri', 'literal'],\n", - " 'o:is_required': False,\n", - " 'o:is_private': False},\n", - " {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/708',\n", - " 'o:id': 708},\n", - " 'o:alternate_label': None,\n", - " 'o:alternate_comment': None,\n", - " 'o:data_type': ['numeric:timestamp', 'literal'],\n", - " 'o:is_required': False,\n", - " 'o:is_private': False},\n", - " {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/1468',\n", - " 'o:id': 1468},\n", - " 'o:alternate_label': None,\n", - " 'o:alternate_comment': None,\n", - " 'o:data_type': ['customvocab:1'],\n", - " 'o:is_required': False,\n", - " 'o:is_private': False},\n", - " {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/766',\n", - " 'o:id': 766},\n", - " 'o:alternate_label': None,\n", - " 'o:alternate_comment': 'Place|Heritage place|State|Country',\n", - " 'o:data_type': ['resource:item', 'uri', 'literal'],\n", - " 'o:is_required': False,\n", - " 'o:is_private': False},\n", - " {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/922',\n", - " 'o:id': 922},\n", - " 'o:alternate_label': None,\n", - " 'o:alternate_comment': 'Person',\n", - " 'o:data_type': ['resource:item', 'uri'],\n", - " 'o:is_required': False,\n", - " 'o:is_private': False},\n", - " {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/265',\n", - " 'o:id': 265},\n", - " 'o:alternate_label': None,\n", - " 'o:alternate_comment': 'Person',\n", - " 'o:data_type': ['resource:item', 'uri'],\n", - " 'o:is_required': False,\n", - " 'o:is_private': False},\n", - " {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/1209',\n", - " 'o:id': 1209},\n", - " 'o:alternate_label': None,\n", - " 'o:alternate_comment': None,\n", - " 'o:data_type': [],\n", - " 'o:is_required': False,\n", - " 'o:is_private': False},\n", - " {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/1384',\n", - " 'o:id': 1384},\n", - " 'o:alternate_label': None,\n", - " 'o:alternate_comment': 'Person',\n", - " 'o:data_type': ['resource:item', 'uri'],\n", - " 'o:is_required': False,\n", - " 'o:is_private': False},\n", - " {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/1358',\n", - " 'o:id': 1358},\n", - " 'o:alternate_label': None,\n", - " 'o:alternate_comment': 'Person',\n", - " 'o:data_type': ['resource:item', 'uri'],\n", - " 'o:is_required': False,\n", - " 'o:is_private': False},\n", - " {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/870',\n", - " 'o:id': 870},\n", - " 'o:alternate_label': None,\n", - " 'o:alternate_comment': 'Person',\n", - " 'o:data_type': ['resource:item', 'uri'],\n", - " 'o:is_required': False,\n", - " 'o:is_private': False},\n", - " {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/981',\n", - " 'o:id': 981},\n", - " 'o:alternate_label': None,\n", - " 'o:alternate_comment': 'Organisation',\n", - " 'o:data_type': ['resource:item', 'uri', 'literal'],\n", - " 'o:is_required': False,\n", - " 'o:is_private': False},\n", - " {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/1253',\n", - " 'o:id': 1253},\n", - " 'o:alternate_label': None,\n", - " 'o:alternate_comment': 'Organisation',\n", - " 'o:data_type': ['resource:item', 'uri', 'literal'],\n", - " 'o:is_required': False,\n", - " 'o:is_private': False},\n", - " {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/804',\n", - " 'o:id': 804},\n", - " 'o:alternate_label': None,\n", - " 'o:alternate_comment': 'Event',\n", - " 'o:data_type': ['resource:item'],\n", - " 'o:is_required': False,\n", - " 'o:is_private': False},\n", - " {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/588',\n", - " 'o:id': 588},\n", - " 'o:alternate_label': None,\n", - " 'o:alternate_comment': 'Vehicle',\n", - " 'o:data_type': ['resource:item'],\n", - " 'o:is_required': False,\n", - " 'o:is_private': False},\n", - " {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/1391',\n", - " 'o:id': 1391},\n", - " 'o:alternate_label': None,\n", - " 'o:alternate_comment': 'Book|Book chapter|Article|Newspaper article|Archival document|Archival file|Photograph|Art work',\n", - " 'o:data_type': ['resource:item'],\n", - " 'o:is_required': False,\n", - " 'o:is_private': False},\n", - " {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/742',\n", - " 'o:id': 742},\n", - " 'o:alternate_label': None,\n", - " 'o:alternate_comment': None,\n", - " 'o:data_type': ['uri'],\n", - " 'o:is_required': False,\n", - " 'o:is_private': False},\n", - " {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/393',\n", - " 'o:id': 393},\n", - " 'o:alternate_label': None,\n", - " 'o:alternate_comment': None,\n", - " 'o:data_type': ['uri'],\n", - " 'o:is_required': False,\n", - " 'o:is_private': False},\n", - " {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/246',\n", - " 'o:id': 246},\n", - " 'o:alternate_label': None,\n", - " 'o:alternate_comment': None,\n", - " 'o:data_type': ['uri'],\n", - " 'o:is_required': False,\n", - " 'o:is_private': False}]}" - ] - }, - "execution_count": null, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "omeka_auth.upload_template('templates/Person.json')" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -1891,6 +1668,30 @@ "assert test_item['dcterms:title'][0]['value'] == new_item['dcterms:title'][0]['@value']" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "You can also add an item to an existing item set by supplying the `item_set_id` parameter." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Get a random item set id\n", + "random_item_set = random.choice(omeka_auth.get_resources('item_sets')['results'])\n", + "item_set_id = random_item_set['o:id']\n", + "\n", + "# Create a new item using the item set id\n", + "new_item_in_item_set = new_item = omeka_auth.add_item(payload, item_set_id=item_set_id)\n", + "\n", + "# Check that the ids match\n", + "assert new_item_in_item_set['o:item_set'][0]['o:id'] == item_set_id" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -2690,9 +2491,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "In the example below I'm going to manually step through the process of adding a new item to Omeka using the API in order to demonstrate the methods available. But of course the point of using the API is to automate such processes -- joining together the individual steps so they can be embedded into your own systems or workflows.\n", + "In the example below I'm going to manually step through the process of adding a new item to Omeka using the API in order to demonstrate the methods available. But of course the point of using the API is to automate such processes -- joining together the individual steps so they can be embedded into your own systems or workflows. For a more detailed example that uploads Trove newspaper articles from a variety of sources, including Trove searches, Trove lists, and Zotero libraries, see the [GLAM Workbench](https://glam-workbench.net/trove-newspapers/#upload-trove-newspaper-articles-to-omeka-s).\n", "\n", - "Let's suppose we want to add this newspaper article in Trove to our Omeka instance. To take best advantage of Omeka's linked data infrastructure, we'll actually create two resources -- one for the article, and one for the newspaper it was published in.\n", + "Let's suppose we want to add [this newspaper article](http://nla.gov.au/nla.news-article226799674) in Trove to our Omeka instance. To take best advantage of Omeka's linked data infrastructure, we'll actually create two resources -- one for the article, and one for the newspaper it was published in.\n", "\n", "I've already created templates labelled 'Newspaper' and 'Newspaper article'.\n", "\n", diff --git a/docs/api.html b/docs/api.html index 30b7746..a27b870 100644 --- a/docs/api.html +++ b/docs/api.html @@ -829,250 +829,6 @@

Adding items < - - {% endraw %} - - {% raw %} - -
-
- -
-
-
template_payload = omeka.prepare_template_payload('templates/Person.json')
-
- -
-
-
- -
- {% endraw %} - - {% raw %} - -
-
- -
-
-
omeka_auth.upload_template('templates/Person.json')
-
- -
-
-
- -
-
- -
- - - -
-
{'@context': 'https://timsherratt.org/collections/api-context',
- '@id': 'https://timsherratt.org/collections/api/resource_templates/9',
- '@type': 'o:ResourceTemplate',
- 'o:id': 9,
- 'o:label': 'Person',
- 'o:owner': {'@id': 'https://timsherratt.org/collections/api/users/1',
-  'o:id': 1},
- 'o:resource_class': {'@id': 'https://timsherratt.org/collections/api/resource_classes/492',
-  'o:id': 492},
- 'o:title_property': {'@id': 'https://timsherratt.org/collections/api/properties/1116',
-  'o:id': 1116},
- 'o:description_property': {'@id': 'https://timsherratt.org/collections/api/properties/528',
-  'o:id': 528},
- 'o:resource_template_property': [{'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/1116',
-    'o:id': 1116},
-   'o:alternate_label': None,
-   'o:alternate_comment': None,
-   'o:data_type': ['literal'],
-   'o:is_required': True,
-   'o:is_private': False},
-  {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/1199',
-    'o:id': 1199},
-   'o:alternate_label': None,
-   'o:alternate_comment': None,
-   'o:data_type': ['uri'],
-   'o:is_required': False,
-   'o:is_private': False},
-  {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/528',
-    'o:id': 528},
-   'o:alternate_label': None,
-   'o:alternate_comment': None,
-   'o:data_type': ['literal'],
-   'o:is_required': False,
-   'o:is_private': False},
-  {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/417',
-    'o:id': 417},
-   'o:alternate_label': None,
-   'o:alternate_comment': None,
-   'o:data_type': [],
-   'o:is_required': False,
-   'o:is_private': False},
-  {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/1144',
-    'o:id': 1144},
-   'o:alternate_label': None,
-   'o:alternate_comment': None,
-   'o:data_type': [],
-   'o:is_required': False,
-   'o:is_private': False},
-  {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/282',
-    'o:id': 282},
-   'o:alternate_label': None,
-   'o:alternate_comment': None,
-   'o:data_type': ['literal'],
-   'o:is_required': False,
-   'o:is_private': False},
-  {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/1357',
-    'o:id': 1357},
-   'o:alternate_label': None,
-   'o:alternate_comment': None,
-   'o:data_type': ['numeric:timestamp', 'literal'],
-   'o:is_required': False,
-   'o:is_private': False},
-  {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/1464',
-    'o:id': 1464},
-   'o:alternate_label': None,
-   'o:alternate_comment': None,
-   'o:data_type': ['customvocab:1'],
-   'o:is_required': False,
-   'o:is_private': False},
-  {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/1042',
-    'o:id': 1042},
-   'o:alternate_label': None,
-   'o:alternate_comment': 'Place|Heritage place|State|Country',
-   'o:data_type': ['resource:item', 'uri', 'literal'],
-   'o:is_required': False,
-   'o:is_private': False},
-  {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/708',
-    'o:id': 708},
-   'o:alternate_label': None,
-   'o:alternate_comment': None,
-   'o:data_type': ['numeric:timestamp', 'literal'],
-   'o:is_required': False,
-   'o:is_private': False},
-  {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/1468',
-    'o:id': 1468},
-   'o:alternate_label': None,
-   'o:alternate_comment': None,
-   'o:data_type': ['customvocab:1'],
-   'o:is_required': False,
-   'o:is_private': False},
-  {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/766',
-    'o:id': 766},
-   'o:alternate_label': None,
-   'o:alternate_comment': 'Place|Heritage place|State|Country',
-   'o:data_type': ['resource:item', 'uri', 'literal'],
-   'o:is_required': False,
-   'o:is_private': False},
-  {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/922',
-    'o:id': 922},
-   'o:alternate_label': None,
-   'o:alternate_comment': 'Person',
-   'o:data_type': ['resource:item', 'uri'],
-   'o:is_required': False,
-   'o:is_private': False},
-  {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/265',
-    'o:id': 265},
-   'o:alternate_label': None,
-   'o:alternate_comment': 'Person',
-   'o:data_type': ['resource:item', 'uri'],
-   'o:is_required': False,
-   'o:is_private': False},
-  {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/1209',
-    'o:id': 1209},
-   'o:alternate_label': None,
-   'o:alternate_comment': None,
-   'o:data_type': [],
-   'o:is_required': False,
-   'o:is_private': False},
-  {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/1384',
-    'o:id': 1384},
-   'o:alternate_label': None,
-   'o:alternate_comment': 'Person',
-   'o:data_type': ['resource:item', 'uri'],
-   'o:is_required': False,
-   'o:is_private': False},
-  {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/1358',
-    'o:id': 1358},
-   'o:alternate_label': None,
-   'o:alternate_comment': 'Person',
-   'o:data_type': ['resource:item', 'uri'],
-   'o:is_required': False,
-   'o:is_private': False},
-  {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/870',
-    'o:id': 870},
-   'o:alternate_label': None,
-   'o:alternate_comment': 'Person',
-   'o:data_type': ['resource:item', 'uri'],
-   'o:is_required': False,
-   'o:is_private': False},
-  {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/981',
-    'o:id': 981},
-   'o:alternate_label': None,
-   'o:alternate_comment': 'Organisation',
-   'o:data_type': ['resource:item', 'uri', 'literal'],
-   'o:is_required': False,
-   'o:is_private': False},
-  {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/1253',
-    'o:id': 1253},
-   'o:alternate_label': None,
-   'o:alternate_comment': 'Organisation',
-   'o:data_type': ['resource:item', 'uri', 'literal'],
-   'o:is_required': False,
-   'o:is_private': False},
-  {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/804',
-    'o:id': 804},
-   'o:alternate_label': None,
-   'o:alternate_comment': 'Event',
-   'o:data_type': ['resource:item'],
-   'o:is_required': False,
-   'o:is_private': False},
-  {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/588',
-    'o:id': 588},
-   'o:alternate_label': None,
-   'o:alternate_comment': 'Vehicle',
-   'o:data_type': ['resource:item'],
-   'o:is_required': False,
-   'o:is_private': False},
-  {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/1391',
-    'o:id': 1391},
-   'o:alternate_label': None,
-   'o:alternate_comment': 'Book|Book chapter|Article|Newspaper article|Archival document|Archival file|Photograph|Art work',
-   'o:data_type': ['resource:item'],
-   'o:is_required': False,
-   'o:is_private': False},
-  {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/742',
-    'o:id': 742},
-   'o:alternate_label': None,
-   'o:alternate_comment': None,
-   'o:data_type': ['uri'],
-   'o:is_required': False,
-   'o:is_private': False},
-  {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/393',
-    'o:id': 393},
-   'o:alternate_label': None,
-   'o:alternate_comment': None,
-   'o:data_type': ['uri'],
-   'o:is_required': False,
-   'o:is_private': False},
-  {'o:property': {'@id': 'https://timsherratt.org/collections/api/properties/246',
-    'o:id': 246},
-   'o:alternate_label': None,
-   'o:alternate_comment': None,
-   'o:data_type': ['uri'],
-   'o:is_required': False,
-   'o:is_private': False}]}
-
- -
- -
-
-
{% endraw %} @@ -1533,6 +1289,37 @@

Add a simple item
+
+

You can also add an item to an existing item set by supplying the item_set_id parameter.

+ +
+
+ + {% raw %} + +
+
+ +
+
+
random_item_set = random.choice(omeka_auth.get_resources('item_sets')['results'])
+item_set_id = random_item_set['o:id']
+
+# Create a new item using the item set id
+new_item_in_item_set = new_item = omeka_auth.add_item(payload, item_set_id=item_set_id)
+
+# Check that the ids match
+assert new_item_in_item_set['o:item_set'][0]['o:id'] == item_set_id
+
+ +
+
+
+
{% endraw %} @@ -2471,8 +2258,8 @@

Example: adding a newspa
-

In the example below I'm going to manually step through the process of adding a new item to Omeka using the API in order to demonstrate the methods available. But of course the point of using the API is to automate such processes -- joining together the individual steps so they can be embedded into your own systems or workflows.

-

Let's suppose we want to add this newspaper article in Trove to our Omeka instance. To take best advantage of Omeka's linked data infrastructure, we'll actually create two resources -- one for the article, and one for the newspaper it was published in.

+

In the example below I'm going to manually step through the process of adding a new item to Omeka using the API in order to demonstrate the methods available. But of course the point of using the API is to automate such processes -- joining together the individual steps so they can be embedded into your own systems or workflows. For a more detailed example that uploads Trove newspaper articles from a variety of sources, including Trove searches, Trove lists, and Zotero libraries, see the GLAM Workbench.

+

Let's suppose we want to add this newspaper article in Trove to our Omeka instance. To take best advantage of Omeka's linked data infrastructure, we'll actually create two resources -- one for the article, and one for the newspaper it was published in.

I've already created templates labelled 'Newspaper' and 'Newspaper article'.

Let's start with the newspaper. First we need to find out the numeric identifier Omeka is using for the Newspaper template. We can use OmekaAPIClient.get_template_by_label to find out.

diff --git a/omeka_s_tools/__init__.py b/omeka_s_tools/__init__.py index 3dc1f76..485f44a 100644 --- a/omeka_s_tools/__init__.py +++ b/omeka_s_tools/__init__.py @@ -1 +1 @@ -__version__ = "0.1.0" +__version__ = "0.1.1" diff --git a/omeka_s_tools/api.py b/omeka_s_tools/api.py index 5e0b82f..5f2c949 100644 --- a/omeka_s_tools/api.py +++ b/omeka_s_tools/api.py @@ -306,7 +306,7 @@ def add_item(self, payload, media_files=None, template_id=None, class_id=None, i if class_id: payload['o:resource_class'] = self.format_resource_id(class_id, 'resource_classes') if item_set_id: - payload['o:item_set'] = self.format_resource_id(template_id, 'item_sets') + payload['o:item_set'] = self.format_resource_id(item_set_id, 'item_sets') if media_files: files = self.add_media_to_payload(payload, media_files) response = self.s.post(f'{self.api_url}/items', files=files, params=self.params) diff --git a/settings.ini b/settings.ini index ee338f9..8faaffd 100644 --- a/settings.ini +++ b/settings.ini @@ -13,7 +13,7 @@ author = Tim Sherratt author_email = tim@timsherratt.org copyright = Tim Sherratt branch = master -version = 0.1.0 +version = 0.1.1 min_python = 3.8 audience = Developers language = English