Skip to content

Commit

Permalink
Merge pull request #20 from uktrade/HOTFIX-details-page-bug
Browse files Browse the repository at this point in the history
Forces Django into thinking nan values are strings. Uses request to b…
  • Loading branch information
gdbarnes authored Oct 15, 2024
2 parents ee085d8 + b66e676 commit f88a6a6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 deletions.
16 changes: 1 addition & 15 deletions orp/orp_search/templates/orp.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,24 +190,10 @@ <h2 class="govuk-fieldset__heading">
</button>
<hr class="govuk-section-break govuk-section-break--m govuk-section-break--visible">
<p class="govuk-body">
<a id="download-csv-link" href="#"
<a id="download-csv-link" href="download_csv/?{{ request.META.QUERY_STRING }}"
class="govuk-link govuk-link--no-visited-state govuk-!-float-right">Download search results as CSV
file</a>
</p>

<script>
// Function to get the current query parameters from the address bar
function getQueryParameters() {
return window.location.search;
}

document.addEventListener('DOMContentLoaded', function () {
var csvLink = document.getElementById('download-csv-link');
var queryParams = getQueryParameters();
var baseURL = '{% url "download_csv" %}';
csvLink.href = baseURL + queryParams;
});
</script>
</form>
</div>

Expand Down
14 changes: 7 additions & 7 deletions orp/orp_search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ def document(request: HttpRequest, id) -> HttpResponse:
public_gateway = PublicGateway()
try:
search_result = public_gateway.search(config)
logger.info("search result: %s", search_result)
# logger.info("search result: %s", search_result)

if "regulatory_topics" in search_result:
search_result["regulatory_topics"] = search_result[
"regulatory_topics"
].split("\n")
search_result["regulatory_topics"] = str(
search_result["regulatory_topics"]
).split("\n")

if "related_legislation" in search_result:
search_result["related_legislation"] = search_result[
"related_legislation"
].split("\n")
search_result["related_legislation"] = str(
search_result["related_legislation"]
).split("\n")

context["result"] = search_result
return render(request, template_name="document.html", context=context)
Expand Down

0 comments on commit f88a6a6

Please sign in to comment.