diff --git a/fec/home/templatetags/filters.py b/fec/home/templatetags/filters.py index d33ae4f3bf..6c65f42a67 100644 --- a/fec/home/templatetags/filters.py +++ b/fec/home/templatetags/filters.py @@ -66,6 +66,15 @@ def web_app_url(path): return "{}{}".format(settings.FEC_APP_URL, path) +@register.filter(name='remove_title_pre_suf_fix') +def remove_title_pre_suf_fix(str): + """ + Removes 'FEC | ' prefix and ' - FEC.gov' suffix' from search.gov search result title + """ + str = re.sub(r'(^FEC \| | - FEC\.gov$)', '', str) + return str + + @register.filter() def highlight_matches(text): """ @@ -189,3 +198,5 @@ def get_file_type(value): file_type = "EXCEL" if xl else file_extension return file_type + + diff --git a/fec/search/templates/search/search.html b/fec/search/templates/search/search.html index 8a8e716188..0be75d5867 100644 --- a/fec/search/templates/search/search.html +++ b/fec/search/templates/search/search.html @@ -162,7 +162,7 @@

Other pages

{% for result in results.site.results %}
  • - {{ result.title | highlight_matches }} + {{ result.title | remove_title_pre_suf_fix | highlight_matches }}

    {{ result.url }}

    {{ result.snippet | highlight_matches }}