Skip to content

Commit

Permalink
[QCDP24-26] renamed the facet name
Browse files Browse the repository at this point in the history
  • Loading branch information
awset committed Sep 8, 2024
1 parent becb78c commit 37b21a6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions ckanext/datarequests/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ def list_datarequests(context, data_dict):
tk.check_access(constants.LIST_DATAREQUESTS, context, data_dict)

# Get the organization
requesting_organisation = data_dict.get('organization_id', None)
requesting_organisation = data_dict.get('requesting_organisation', None)
if requesting_organisation:
# Get organization ID (organization name is received sometimes)
requesting_organisation = organization_show({'ignore_auth': True}, {'id': requesting_organisation}).get('id')
Expand Down Expand Up @@ -524,11 +524,11 @@ def list_datarequests(context, data_dict):
no_processed_status_facet[status] += 1

# Format facets
organization_facet = []
requesting_organization_facet = []
for requesting_organisation in no_processed_organization_facet:
try:
organization = organization_show({'ignore_auth': True}, {'id': requesting_organisation})
organization_facet.append({
requesting_organization_facet.append({
'name': organization.get('name'),
'display_name': organization.get('display_name'),
'count': no_processed_organization_facet[requesting_organisation]
Expand All @@ -552,8 +552,8 @@ def list_datarequests(context, data_dict):
}

# Facets can only be included if they contain something
if organization_facet:
result['facets']['organization'] = {'items': organization_facet}
if requesting_organization_facet:
result['facets']['requesting_organisation'] = {'items': requesting_organization_facet}

if status_facet:
result['facets']['status'] = {'items': status_facet}
Expand Down
16 changes: 8 additions & 8 deletions ckanext/datarequests/controllers/controller_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _get_context():
'user': c.user, 'auth_user_obj': c.userobj}


def _show_index(user_id, organization_id, include_organization_facet, url_func, file_to_render, extra_vars=None):
def _show_index(user_id, requesting_organisation, include_organization_facet, url_func, file_to_render, extra_vars=None):
def pager_url(status=None, sort=None, q=None, page=None):
params = []

Expand Down Expand Up @@ -88,8 +88,8 @@ def pager_url(status=None, sort=None, q=None, page=None):
if q:
data_dict['q'] = q

if organization_id:
data_dict['organization_id'] = organization_id
if requesting_organisation:
data_dict['requesting_organisation'] = requesting_organisation

if user_id:
data_dict['user_id'] = user_id
Expand All @@ -105,7 +105,7 @@ def pager_url(status=None, sort=None, q=None, page=None):
c.filters = [(tk._('Newest'), 'desc'), (tk._('Oldest'), 'asc')]
c.sort = sort
c.q = q
c.organization = organization_id
c.requesting_organisation = requesting_organisation
c.status = status
c.datarequest_count = datarequests_list['count']
c.datarequests = datarequests_list['result']
Expand All @@ -123,14 +123,14 @@ def pager_url(status=None, sort=None, q=None, page=None):

# Organization facet cannot be shown when the user is viewing an org
if include_organization_facet is True:
c.facet_titles['organization'] = tk._('Organizations')
c.facet_titles['requesting_organisation'] = tk._('Organizations')

if not extra_vars:
extra_vars = {}
extra_vars['filters'] = c.filters
extra_vars['sort'] = c.sort
extra_vars['q'] = c.q
extra_vars['organization'] = c.organization
extra_vars['requesting_organisation'] = c.requesting_organisation
extra_vars['status'] = c.status
extra_vars['datarequest_count'] = c.datarequest_count
extra_vars['datarequests'] = c.datarequests
Expand All @@ -141,7 +141,7 @@ def pager_url(status=None, sort=None, q=None, page=None):
extra_vars['user'] = None
if 'user_dict' not in extra_vars:
extra_vars['user_dict'] = None
extra_vars['group_type'] = 'organization'
extra_vars['group_type'] = 'requesting_organisation'
return tk.render(file_to_render, extra_vars=extra_vars)
except ValueError as e:
# This exception should only occur if the page value is not valid
Expand All @@ -153,7 +153,7 @@ def pager_url(status=None, sort=None, q=None, page=None):


def index():
return _show_index(None, request_helpers.get_first_query_param('organization', ''), True, search_url,
return _show_index(None, request_helpers.get_first_query_param('requesting_organisation', ''), True, search_url,
'datarequests/index.html')


Expand Down
2 changes: 1 addition & 1 deletion ckanext/datarequests/templates/datarequests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<section class="module">
<div class="module-content">
{% block page_primary_action %}
{% snippet 'snippets/custom_search_form.html', query=q, fields=(('organization', organization), ('state', state)), sorting=filters, sorting_selected=sort, placeholder=_('Search Data Requests...'), no_bottom_border=true, count=datarequest_count, no_title=True %}
{% snippet 'snippets/custom_search_form.html', query=q, fields=(('requesting_organisation', requesting_organisation), ('state', state)), sorting=filters, sorting_selected=sort, placeholder=_('Search Data Requests...'), no_bottom_border=true, count=datarequest_count, no_title=True %}
{{ h.snippet('datarequests/snippets/datarequest_list.html', datarequest_count=datarequest_count, datarequests=datarequests, page=page, q=q)}}
{% endblock %}
</div>
Expand Down

0 comments on commit 37b21a6

Please sign in to comment.