Skip to content

Commit

Permalink
Change Custom text in RSS feed, pass fq params from snippets to feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
Jovanka committed Aug 28, 2024
1 parent b105ba6 commit f0fc4e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion ckanext/datasetsnippets/blueprints/feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def _package_search(data_dict):
u'user': g.user,
u'auth_user_obj': g.userobj
}

if u'sort' not in data_dict or not data_dict['sort']:
data_dict['sort'] = u'metadata_modified desc'

Expand Down Expand Up @@ -394,7 +395,7 @@ def custom():

return output_feed(
results,
feed_title=u'%s - Custom query' % SITE_TITLE,
feed_title=u'%s - Datasets' % SITE_TITLE,
feed_description=u'Recently created or updated'
' datasets on %s. Custom query: \'%s\'' % (SITE_TITLE, q),
feed_link=alternate_url,
Expand Down
5 changes: 4 additions & 1 deletion ckanext/datasetsnippets/blueprints/snippet_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def read_dataset(id):

return _finish(200, data)


def search_dataset():
from ckan.lib.search import SearchError, SearchQueryError

Expand Down Expand Up @@ -188,12 +189,14 @@ def remove_field(key, value=None, replace=None):
c.fields_grouped = {}
search_extras = {}
fq = ''
feed_params = ''
for (param, value) in request.args.items(multi=True):
# remove the root_breadcrumb parameter if present (will confuse search)
if param not in ['q', 'page', 'sort', 'root_breadcrumb'] \
and len(value) and not param.startswith('_'):
c.fields.append((param, value))
fq += f' {param}:"{value}"'
feed_params += u'%s="%s"' % (param, value)
c.fields_grouped.setdefault(param, [])
c.fields_grouped[param].append(value)

Expand Down Expand Up @@ -250,7 +253,7 @@ def remove_field(key, value=None, replace=None):
# that search function is taking, in order to produce the results for the feeds
from ckanext.datasetsnippets.blueprints import feeds
fq_feed = fq.replace('+dataset_type:dataset', '')
feed = 'drupal_feeds/custom.rss?q=' + q + '&' + fq_feed
feed = 'drupal_feeds/custom.rss?q=' + q + '&' + feed_params + '&' + sort_by
c.feed = feed

c.page = h.Page(
Expand Down

0 comments on commit f0fc4e0

Please sign in to comment.