Skip to content

Commit

Permalink
[#430] Fix for packages not appearing in vocabulary_show
Browse files Browse the repository at this point in the history
  • Loading branch information
johnglover committed Mar 19, 2013
1 parent 14eb73d commit 5c95483
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions ckan/lib/dictization/model_dictize.py
Expand Up @@ -393,15 +393,25 @@ def tag_dictize(tag, context):
tag_dict = d.table_dictize(tag, context)
query = search.PackageSearchQuery()

q = {'q': '+tags:"%s" +capacity:public' % tag.name, 'fl': 'data_dict',
'wt': 'json', 'rows': 1000}
tag_query = u'+capacity:public '
vocab_id = tag_dict.get('vocabulary_id')

package_dicts = [h.json.loads(result['data_dict']) for result in query.run(q)['results']]
if vocab_id:
model = context['model']
vocab = model.Vocabulary.get(vocab_id)
tag_query += u'+vocab_{0}:"{1}"'.format(vocab.name, tag.name)
else:
tag_query += u'+tags:"{0}"'.format(tag.name)

q = {'q': tag_query, 'fl': 'data_dict', 'wt': 'json', 'rows': 1000}

package_dicts = [h.json.loads(result['data_dict'])
for result in query.run(q)['results']]

# Add display_names to tags. At first a tag's display_name is just the
# same as its name, but the display_name might get changed later (e.g.
# translated into another language by the multilingual extension).
assert not tag_dict.has_key('display_name')
assert 'display_name' not in tag_dict
tag_dict['display_name'] = tag_dict['name']

if context.get('for_view'):
Expand Down

0 comments on commit 5c95483

Please sign in to comment.