Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into 430-packages-missin…
Browse files Browse the repository at this point in the history
…g-vocabulary-show
  • Loading branch information
johnglover committed Mar 19, 2013
2 parents 5c95483 + 579ee38 commit 9698b35
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 14 deletions.
5 changes: 4 additions & 1 deletion ckan/controllers/group.py
Expand Up @@ -192,7 +192,10 @@ def _read(self, id, limit):

q = c.q = request.params.get('q', '')
# Search within group
q += ' groups: "%s"' % c.group_dict.get('name')
if c.group_dict.get('is_organization'):
q += ' owner_org: "%s"' % c.group_dict.get('id')
else:
q += ' groups: "%s"' % c.group_dict.get('name')

try:
description_formatted = ckan.misc.MarkdownFormat().to_html(
Expand Down
8 changes: 7 additions & 1 deletion ckan/lib/app_globals.py
Expand Up @@ -109,9 +109,15 @@ def get_config_value(key, default=''):
value = model.get_system_info(key)
else:
value = None
config_value = config.get(key)
# sort encodeings if needed
if isinstance(config_value, str):
try:
config_value = config_value.decode('utf-8')
except UnicodeDecodeError:
config_value = config_value.decode('latin-1')
# we want to store the config the first time we get here so we can
# reset them if needed
config_value = config.get(key)
if key not in _CONFIG_CACHE:
_CONFIG_CACHE[key] = config_value
if value is not None:
Expand Down
12 changes: 9 additions & 3 deletions ckan/lib/dictization/model_dictize.py
Expand Up @@ -23,7 +23,7 @@ def group_list_dictize(obj_list, context,
query = search.PackageSearchQuery()

q = {'q': '+capacity:public' if not with_private else '*:*',
'fl': 'groups', 'facet.field': ['groups'],
'fl': 'groups', 'facet.field': ['groups', 'owner_org'],
'facet.limit': -1, 'rows': 1}

query.run(q)
Expand All @@ -42,7 +42,10 @@ def group_list_dictize(obj_list, context,

group_dict['display_name'] = obj.display_name

group_dict['packages'] = query.facets['groups'].get(obj.name, 0)
if obj.is_organization:
group_dict['packages'] = query.facets['owner_org'].get(obj.id, 0)
else:
group_dict['packages'] = query.facets['groups'].get(obj.name, 0)

if context.get('for_view'):
if group_dict['is_organization']:
Expand Down Expand Up @@ -336,7 +339,10 @@ def group_dictize(group, context):
context)

query = search.PackageSearchQuery()
q = {'q': 'groups:"%s" +capacity:public' % group.name, 'rows': 1}
if group.is_organization:
q = {'q': 'owner_org:"%s" +capacity:public' % group.id, 'rows': 1}
else:
q = {'q': 'groups:"%s" +capacity:public' % group.name, 'rows': 1}
result_dict['package_count'] = query.run(q)['count']

result_dict['tags'] = tag_list_dictize(
Expand Down
6 changes: 4 additions & 2 deletions ckan/lib/search/index.py
Expand Up @@ -157,8 +157,10 @@ def index_package(self, pkg_dict, defer_commit=False):

# if there is an owner_org we want to add this to groups for index
# purposes
if pkg_dict.get('organization'):
pkg_dict['groups'].append(pkg_dict['organization']['name'])
if pkg_dict['owner_org'] and pkg_dict.get('organization'):
pkg_dict['organization'] = pkg_dict['organization']['name']
else:
pkg_dict['organization'] = None


# tracking
Expand Down
2 changes: 1 addition & 1 deletion ckan/logic/action/get.py
Expand Up @@ -1323,7 +1323,7 @@ def package_search(context, data_dict):
for key_, value_ in value.items():
new_facet_dict = {}
new_facet_dict['name'] = key_
if key == 'groups':
if key in ('groups', 'organization'):
group = model.Group.get(key_)
if group:
new_facet_dict['display_name'] = group.display_name
Expand Down
1 change: 1 addition & 0 deletions ckan/public/base/less/module.less
Expand Up @@ -3,6 +3,7 @@
}

.module-heading {
.clearfix;
margin: 0;
padding: 7px @gutterX;
font-size: 14px;
Expand Down
3 changes: 2 additions & 1 deletion ckan/templates/organization/bulk_process.html
Expand Up @@ -6,7 +6,8 @@
<div class="clearfix">
<h1 class="hide-heading">{{ _('Edit datasets') }}</h1>
<div class="primary">
<h3>
{% link_for _('Add Dataset'), controller='package', action='new', group=c.group_dict.id, class_='btn pull-right', icon='plus-sign-alt' %}
<h3 class="page-heading">
{%- if c.page.item_count -%}
{{ c.page.item_count }} datasets{{ _(" found for \"{query}\"").format(query=c.q) if c.q }}
{%- elif request.params -%}
Expand Down
8 changes: 3 additions & 5 deletions ckan/templates/organization/members.html
Expand Up @@ -4,8 +4,9 @@

{% block primary_content_inner %}
<div class="module-content">
<h1 class="hide-heading">{{ _('Members') }}</h1>
<table class="table table-bordered">
{% link_for _('Add Member'), controller='organization', action='member_new', id=c.group_dict.id, class_='btn pull-right', icon='plus-sign-alt' %}
<h3 class="page-heading">{{ _('{0} members'.format(c.members|length)) }}</h3>
<table class="table table-header table-hover table-bordered">
<col width="70" />
<col width="40" />
<col width="20" />
Expand Down Expand Up @@ -36,8 +37,5 @@ <h1 class="hide-heading">{{ _('Members') }}</h1>
{% endfor %}
</tbody>
</table>
<div class="form-actions">
{% link_for _('Add member'), controller='organization', action='member_new', id=c.group_dict.id, class_='btn btn-primary' %}
</div>
</div>
{% endblock %}

0 comments on commit 9698b35

Please sign in to comment.