Skip to content

Commit

Permalink
Remove the view to export links from an individual NOFO
Browse files Browse the repository at this point in the history
We were not using this, it was a one-off.

Plus, the new script handles this same functionality.

The best code is no code at all.™️
  • Loading branch information
pcraig3 committed Nov 22, 2024
1 parent 6f7b6b4 commit 10c73d4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 29 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve

### Changed

### Removed

- Remove admin-only view to export all NOFO links
- We used this once ever

### Fixed

- Replace "www.grants.gov/web/grants/search-grants.html" with "grants.gov/search-grants"
Expand Down
3 changes: 0 additions & 3 deletions bloom_nofos/nofos/templates/admin/nofo_change_form.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{% extends "admin/change_form.html" %}

{% block object-tools-items %}
<li>
<a href="{% url 'nofos:export_nofo_links' original.id %}">Export URLs</a>
</li>
{{ block.super }}
{% endblock %}
5 changes: 0 additions & 5 deletions bloom_nofos/nofos/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,4 @@
views.CheckNOFOLinkSingleView.as_view(),
name="nofo_check_link_single",
),
path(
"<int:nofo_id>/export_nofo_links",
views.export_nofo_links,
name="export_nofo_links",
),
]
21 changes: 0 additions & 21 deletions bloom_nofos/nofos/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import csv
import io

import docraptor
Expand All @@ -8,7 +7,6 @@
from django.conf import settings
from django.contrib import messages
from django.contrib.admin.views.decorators import staff_member_required
from django.contrib.auth.decorators import user_passes_test
from django.core.exceptions import PermissionDenied
from django.db import transaction
from django.db.models import F
Expand Down Expand Up @@ -897,22 +895,3 @@ def insert_order_space_view(request, section_id):

context = {"form": form, "title": "Insert Order Space", "section": section}
return render(request, "admin/insert_order_space.html", context)


@user_passes_test(lambda u: u.is_superuser)
def export_nofo_links(request, nofo_id):
# Create the HttpResponse object with the appropriate CSV header.
response = HttpResponse(content_type="text/csv")
response["Content-Disposition"] = f'attachment; filename="nofo_{nofo_id}_links.csv"'

writer = csv.writer(response)

writer.writerow(["url", "section_name", "nofo_number"])

nofo = get_object_or_404(Nofo, id=nofo_id)

urls = find_external_links(nofo)
for url in urls:
writer.writerow([url.get("url"), url.get("section").name, nofo.number])

return response

0 comments on commit 10c73d4

Please sign in to comment.