Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add platform admin page for uuid queries #1965

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open

Conversation

sastels
Copy link
Collaborator

@sastels sastels commented Oct 4, 2024

Summary | Résumé

Add a page to allow queries of arbitrary uuids (notifications/services/templates/users/jobs) and get the relevant links.

image

Test instructions | Instructions pour tester la modification

  • Run this locally connected to the staging api or use the review app.
  • Go to the platform admin / Search for ids page and search away.

Copy link

github-actions bot commented Oct 4, 2024

app/config.py Outdated
@@ -25,8 +25,7 @@ class Config(object):
ALLOW_DEBUG_ROUTE = env.bool("ALLOW_DEBUG_ROUTE", False)

# List of allowed service IDs that are allowed to send HTML through their templates.
ALLOW_HTML_SERVICE_IDS: List[str] = [
id.strip() for id in os.getenv("ALLOW_HTML_SERVICE_IDS", "").split(",")]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the changes in this file were done by make format.

app/utils.py Outdated
@@ -93,7 +93,7 @@ def from_lambda_api(line):
return isinstance(line, dict)


@cache.memoize(timeout=12*60*60)
@cache.memoize(timeout=12 * 60 * 60)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make format

@sastels sastels marked this pull request as ready for review October 17, 2024 17:51
@@ -165,6 +166,7 @@ def get_locale():
provider_client,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new import support_api_client should be added in alphabetical order to maintain consistency with the other imports.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is in the right order. 🤖

@@ -1329,6 +1329,13 @@ class SearchUsersByEmailForm(StripWhitespaceForm):
)


class SearchIds(StripWhitespaceForm):
search = SearchField(
_l("List of IDs"),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider renaming the label from 'List of IDs' to 'List of UUIDs' to be more specific about the expected input.

class SearchIds(StripWhitespaceForm):
search = SearchField(
_l("List of IDs"),
validators=[DataRequired(_l("You need to enter one or more UUIDs to search by."))],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validation message 'You need to enter one or more UUIDs to search by.' should be updated to 'You need to enter one or more valid UUIDs to search by.' to clarify that the input should be valid UUIDs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That won't make much difference.

form = SearchIds()
records = None
if form.validate_on_submit():
records = support_api_client.find_ids(form.search.data)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding error handling for the support_api_client.find_ids call to manage potential exceptions or errors from the API.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A generally good idea, but in this case if there's a server error with api then it's fine for the admin web page to show an error.

self.notify_service_id = app.config["NOTIFY_SERVICE_ID"]

def find_ids(self, ids):
data = self.get("/support/find-ids", params={"ids": ids})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding error handling for the self.get method to manage potential exceptions or unsuccessful responses.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nah, just show the error in the web app.

_data={"search": "1234"},
_expected_status=200,
)
get_records.assert_called_once_with("1234")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using a more specific assertion for the number of search inputs to ensure the test is more robust.

_expected_status=200,
)
get_records.assert_called_once_with("1234")
results = document.findAll("a", {"class": "browse-list-link"})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using find_all instead of findAll for consistency with modern BeautifulSoup conventions.

_expected_status=200,
)
get_records.assert_called_once_with("1234")
results = document.findAll("a", {"class": "browse-list-link"})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using find_all instead of findAll for consistency with modern BeautifulSoup conventions.

_expected_status=200,
)
get_records.assert_called_once_with("1234")
results = document.findAll("a", {"class": "browse-list-link"})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using find_all instead of findAll for consistency with modern BeautifulSoup conventions.

)
document = client_request.post("main.find_ids", _data={"search": "1234,5678"}, _expected_status=200)
get_records.assert_called_once_with("1234,5678")
results = document.findAll("a", {"class": "browse-list-link"})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using find_all instead of findAll for consistency with modern BeautifulSoup conventions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants