Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 90d0ddd

Browse files
author
David Read
committed
[ckan#1886] Change default of tag_show include_datasets to False, like in ckan#2206.
1 parent 72d1707 commit 90d0ddd

3 files changed

Lines changed: 18 additions & 17 deletions

File tree

CHANGELOG.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ Changes and deprecations
3030
* Add middleware that cleans up the response string after it has been
3131
served, stabilizes memory usage for large requests #1847
3232

33-
* The ``vocabulary_show`` API call no longer returns the ``packages`` key -
34-
i.e. datasets that use the vocabulary. ``tag_show`` API call now supports
35-
vocabularies, so that you can get the datasets using a vocabulary tag. In
36-
addition ``tag_show`` has an option not ``include_datasets``, which gives
37-
better performance. (#1886)
33+
* The ``vocabulary_show`` and ``tag_show`` API calls no longer returns the
34+
``packages`` key - i.e. datasets that use the vocabulary or tag.
35+
``tag_show`` now has an ``include_datasets`` option and has been extended
36+
to work with vocabulary tags. (#1886)
3837

3938

4039
v2.3 2015-03-04

ckan/logic/action/get.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,7 @@ def tag_show(context, data_dict):
12801280
:param include_datasets: include a list of the tag's datasets. (Up to a
12811281
limit of 1000 - for more flexibility, use package_search - see
12821282
:py:func:`package_search` for an example.)
1283-
(optional, default: ``True``)
1283+
(optional, default: ``False``)
12841284
:type include_datasets: bool
12851285
12861286
:returns: the details of the tag, including a list of all of the tag's
@@ -1290,7 +1290,7 @@ def tag_show(context, data_dict):
12901290

12911291
model = context['model']
12921292
id = _get_or_bust(data_dict, 'id')
1293-
include_datasets = asbool(data_dict.get('include_datasets', True))
1293+
include_datasets = asbool(data_dict.get('include_datasets', False))
12941294

12951295
tag = model.Tag.get(id, vocab_id_or_name=data_dict.get('vocabulary_id'))
12961296
context['tag'] = tag

ckan/tests/logic/action/test_get.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,6 +1470,14 @@ def test_tag_show_for_free_tag(self):
14701470
eq(tag_shown['display_name'], 'acid-rain')
14711471
eq(tag_shown['id'], tag_in_dataset['id'])
14721472
eq(tag_shown['vocabulary_id'], None)
1473+
assert 'packages' not in tag_shown
1474+
1475+
def test_tag_show_with_datasets(self):
1476+
dataset = factories.Dataset(tags=[{'name': 'acid-rain'}])
1477+
1478+
tag_shown = helpers.call_action('tag_show', id='acid-rain',
1479+
include_datasets=True)
1480+
14731481
eq([d['name'] for d in tag_shown['packages']], [dataset['name']])
14741482

14751483
def test_tag_show_not_found(self):
@@ -1482,7 +1490,8 @@ def test_tag_show_for_flexible_tag(self):
14821490
# and foreign characters in its name
14831491
dataset = factories.Dataset(tags=[{'name': u'Flexible. \u30a1'}])
14841492

1485-
tag_shown = helpers.call_action('tag_show', id=u'Flexible. \u30a1')
1493+
tag_shown = helpers.call_action('tag_show', id=u'Flexible. \u30a1',
1494+
include_datasets=True)
14861495

14871496
eq(tag_shown['name'], u'Flexible. \u30a1')
14881497
eq(tag_shown['display_name'], u'Flexible. \u30a1')
@@ -1495,22 +1504,15 @@ def test_tag_show_for_vocab_tag(self):
14951504
tag_in_dataset = dataset['tags'][0]
14961505

14971506
tag_shown = helpers.call_action('tag_show', id='acid-rain',
1498-
vocabulary_id=vocab['id'])
1507+
vocabulary_id=vocab['id'],
1508+
include_datasets=True)
14991509

15001510
eq(tag_shown['name'], 'acid-rain')
15011511
eq(tag_shown['display_name'], 'acid-rain')
15021512
eq(tag_shown['id'], tag_in_dataset['id'])
15031513
eq(tag_shown['vocabulary_id'], vocab['id'])
15041514
eq([d['name'] for d in tag_shown['packages']], [dataset['name']])
15051515

1506-
def test_tag_show_without_datasets(self):
1507-
factories.Dataset(tags=[{'name': 'acid-rain'}])
1508-
1509-
tag_shown = helpers.call_action('tag_show', id='acid-rain',
1510-
include_datasets=False)
1511-
1512-
assert 'packages' not in tag_shown
1513-
15141516

15151517
class TestTagList(helpers.FunctionalTestBase):
15161518

0 commit comments

Comments
 (0)