Skip to content

Commit

Permalink
Merge pull request #2721 from GSA-TTS/main
Browse files Browse the repository at this point in the history
  • Loading branch information
jadudm authored Nov 3, 2023
2 parents d24f03a + 051ce3c commit 953132f
Show file tree
Hide file tree
Showing 24 changed files with 230 additions and 209 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/new-relic-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Record Deployment And Add New Relic Monitor
on:
push:
branches:
- main
- prod
tags:
- v1.*

jobs:
newrelic:
runs-on: ubuntu-latest
name: New Relic Record Deployment
steps:
# This step builds a var with the release tag value to use later
- name: Set Release Version from Tag
run: echo "RELEASE_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
# This step creates a new Change Tracking Marker
- name: Add New Relic Application Deployment Marker
uses: newrelic/[email protected]
with:
apiKey: ${{ secrets.NEW_RELIC_API_KEY }}
guid: ${{ secrets.NEW_RELIC_DEPLOYMENT_ENTITY_GUID }}
version: "${{ env.RELEASE_VERSION }}"
user: "${{ github.actor }}"

4 changes: 3 additions & 1 deletion backend/.profile
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ export no_proxy="${S3_ENDPOINT_FOR_NO_PROXY},${S3_FIPS_ENDPOINT_FOR_NO_PROXY},${
export NEW_RELIC_LICENSE_KEY="$(echo "$VCAP_SERVICES" | jq --raw-output --arg service_name "newrelic-creds" ".[][] | select(.name == \$service_name) | .credentials.NEW_RELIC_LICENSE_KEY")"

# Set the application name for New Relic telemetry.
#export NEW_RELIC_APP_NAME="$(echo "$VCAP_APPLICATION" | jq -r .application_name)"
# this did not work on preview, so, since gsa-fac-app works, keeping that there
#export NEW_RELIC_APP_NAME="$(echo "$VCAP_APPLICATION" | jq -r .application_name)-$(echo "$VCAP_APPLICATION" | jq -r .space_name)"
export NEW_RELIC_APP_NAME="$(echo "$VCAP_APPLICATION" | jq -r .application_name)-app"


# Set the environment name for New Relic telemetry.
export NEW_RELIC_ENVIRONMENT="$(echo "$VCAP_APPLICATION" | jq -r .space_name)"

Expand Down
File renamed without changes.
24 changes: 24 additions & 0 deletions backend/audit/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,30 @@ def _just_uei_workbooks(uei):
return {k: _just_uei(uei, k) for k in workbooks}


class RootPathTests(TestCase):
"""
Do we return the correct response for both authenticated and unauthenticated
users?
"""

def test_unauthenticated(self):
"""Verify the root path returns 200, unauthenticated."""
result = self.client.get("/")
self.assertEqual(result.status_code, 200)

def test_authenticated(self):
"""Verify the root path redirects, authenticated."""
user = baker.make(User)
self.client.force_login(user=user)
result = self.client.get("/")
self.assertEqual(result.status_code, 302)

def test_no_robots(self):
"""Verify robots.txt returns 200"""
result = self.client.get("/robots.txt")
self.assertEqual(result.status_code, 200)


class MySubmissionsViewTests(TestCase):
def setUp(self):
self.user = baker.make(User)
Expand Down
6 changes: 4 additions & 2 deletions backend/audit/viewlib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
from .home import Home
from .no_robots import no_robots
from .submission_progress_view import ( # noqa
SubmissionProgressView,
submission_progress_check,
)
from .tribal_data_consent import TribalDataConsent

from .upload_report_view import UploadReportView

from .unlock_after_certification import UnlockAfterCertificationView

# In case we want to iterate through all the views for some reason:
views = [
Home,
SubmissionProgressView,
TribalDataConsent,
UnlockAfterCertificationView,
UploadReportView,
no_robots,
]
23 changes: 7 additions & 16 deletions backend/cms/views.py → backend/audit/viewlib/home.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
from .models import Posts
from django.views import generic
from django.shortcuts import render, redirect
from django.urls import reverse
from django.http import HttpResponse


# class based views for posts
class Home(generic.View):
"""
This is for the root path: /
It will return the home template if not authenticated and the audit table if
authenticated.
"""

def get(self, request, *args, **kwargs):
if request.user.is_authenticated:
url = reverse("audit:MySubmissions")
return redirect(url)
template_name = "home.html"
extra_context = {}
return render(request, template_name, extra_context)


# class based view for each post
class postdetail(generic.DetailView):
"""Basic details class"""

model = Posts
template_name = "post.html"


# robots.txt
def NoRobots(context):
content = "User-agent: *\nDisallow: /"
return HttpResponse(content, content_type="text/plain")
9 changes: 9 additions & 0 deletions backend/audit/viewlib/no_robots.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.http import HttpResponse


def no_robots(_context):
"""
Return Disallow for *
"""
content = "User-agent: *\nDisallow: /"
return HttpResponse(content, content_type="text/plain")
2 changes: 2 additions & 0 deletions backend/audit/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@
validate_secondary_auditors_json,
)
from audit.viewlib import ( # noqa
Home,
TribalDataConsent,
SubmissionProgressView,
UnlockAfterCertificationView,
UploadReportView,
no_robots,
submission_progress_check,
)

Expand Down
Empty file removed backend/cms/__init__.py
Empty file.
11 changes: 0 additions & 11 deletions backend/cms/admin.py

This file was deleted.

6 changes: 0 additions & 6 deletions backend/cms/apps.py

This file was deleted.

46 changes: 0 additions & 46 deletions backend/cms/migrations/0001_Create_content_model.py

This file was deleted.

Empty file removed backend/cms/migrations/__init__.py
Empty file.
30 changes: 0 additions & 30 deletions backend/cms/models.py

This file was deleted.

Empty file.
4 changes: 0 additions & 4 deletions backend/cms/tests.py

This file was deleted.

11 changes: 0 additions & 11 deletions backend/cms/urls.py

This file was deleted.

1 change: 0 additions & 1 deletion backend/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@
"api",
"users",
"report_submission",
"cms",
# "data_distro",
"dissemination",
"support",
Expand Down
6 changes: 4 additions & 2 deletions backend/config/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from api import views
from audit import views as auditviews
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
Expand Down Expand Up @@ -73,8 +74,9 @@
),
path("audit/", include("audit.urls")),
path("dissemination/", include("dissemination.urls")),
# Keep last so we can use short urls for content pages like home page etc.
path("", include("cms.urls")),
# home page & robots.txt
path("", auditviews.Home.as_view(), name="Home"),
path("robots.txt", auditviews.no_robots, name="no_robots"),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

if settings.ENABLE_DEBUG_TOOLBAR:
Expand Down
5 changes: 5 additions & 0 deletions backend/dissemination/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class SearchForm(forms.Form):
(x, str(x)) for x in range(2016, 2024)
) # ((2016, "2016"), (2017, "2017"), ..., (2023, "2023"))

# Query params
entity_name = forms.CharField(required=False)
uei_or_ein = forms.CharField(required=False)
aln = forms.CharField(required=False)
Expand All @@ -14,3 +15,7 @@ class SearchForm(forms.Form):
cog_or_oversight = forms.CharField(required=False)
agency_name = forms.CharField(required=False)
audit_year = forms.MultipleChoiceField(choices=AY_choices, required=False)

# Display params
limit = forms.CharField(required=False)
page = forms.CharField(required=False)
2 changes: 1 addition & 1 deletion backend/dissemination/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ def search_general(
fiscal_year_match = Q(audit_year__in=audit_years)
query.add(fiscal_year_match, Q.AND)

results = General.objects.filter(query)
results = General.objects.filter(query).order_by("-fac_accepted_date")

return results
Loading

0 comments on commit 953132f

Please sign in to comment.