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

KYC Verification Report #35765

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

KYC Verification Report #35765

wants to merge 18 commits into from

Conversation

zandre-eng
Copy link
Contributor

@zandre-eng zandre-eng commented Feb 12, 2025

Product Description

A new "KYC Report" page has been added to the "Data" sidebar:
Screenshot from 2025-02-12 16-15-39

Opening this page reveals a new KYC verification report which can be used to verify users:
Screenshot from 2025-02-12 16-15-22

Clicking on "Verify All" will verify all the rows across all pages. Selecting one or more rows will cause this button to say "Verify Selected" and, upon clicking it, will only verify the rows that have been selected.
Screenshot from 2025-02-12 16-22-44

If a row contains invalid and/or missing data, then the invalid columns will be shown as empty (---) and the "Verify" button for that row will be greyed out.

It should be noted that currently clicking on any of the verify buttons doesn't do anything except show a success message on the page. This is because there are followup tickets to implement the actual API call and handle the results thereof.
Screenshot from 2025-02-12 16-24-11

Technical Summary

Link to ticket here.
Link to design spec here.
Link to tech spec here.

This PR adds a new KYC verification report which will allow users to verify the information of one or more users. This report is able to show either mobile workers or cases, depending on what has been configured on the KYC config page.

This report is currently a read-only report in that the user cannot yet do any actual verification on this page. As mentioned earlier, this will be implemented in follow-up tickets.

Feature Flag

KYC_VERIFICATION

Safety Assurance

Safety story

  • Local testing done
  • Unit tests exist
  • Resides behind an unused feature flag.

Automated test coverage

Unit tests exist to ensure that the new views cannot be accessed without authentication or the appropriate feature flag enabled. Additionally, there are also unit tests to make sure that the row data from the report table is correct for both users and cases.

QA Plan

No QA planned.

Rollback instructions

  • This PR can be reverted after deploy with no further considerations

Labels & Review

  • Risk label is set correctly
  • The set of people pinged as reviewers is appropriate for the level of risk of the change

@zandre-eng zandre-eng added the product/feature-flag Change will only affect users who have a specific feature flag enabled label Feb 12, 2025
success_count = 0
fail_count = 0
if verify_all:
# TODO: Need to get all IDS. Could take inspiration from _row_data to fetch all IDs
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These TODOs are related to the follow-up work that still needs to be completed to implement the actual verification API call and response.

@@ -32,3 +35,47 @@ class Meta:
constraints = [
models.UniqueConstraint(fields=['domain', 'provider'], name='unique_domain_provider'),
]


class KycVerifyTable(BaseHtmxTable):
Copy link
Contributor

Choose a reason for hiding this comment

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

@zandre-eng What's your thoughts on putting this table class in a separate tables.py file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great idea! This will help keep things a bit more separate. Addressed in 3508be4.

class KycVerificationReportView(BaseDomainView):
urlname = 'kyc_verify'
template_name = 'kyc/kyc_verify_report.html'
section_name = _("Data")
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: use single quotes

Suggested change
section_name = _("Data")
section_name = _('Data')

Copy link
Contributor

@Charl1996 Charl1996 Feb 13, 2025

Choose a reason for hiding this comment

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

(because the other strings use them and the quotes look out of place)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 64ed0c4.

<p>
<button id="verify-selected-btn" class="btn btn-primary" type="button"
hx-post="{% url 'kyc_verify_table' request.domain %}"
hx-swap="afterBegin"
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the verify-alert div is empty I was slightly surprised that you didn't use innerHTML here. Is there a particular reason you used afterBegin, since the target element does not have child elements? Or is it to allow for multiple alerts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Weirdly, I originally had issues when setting it to innerHTML where the alert ended up popping up in an unexpected place. But testing it now again however, it appears to be working fine. It seems this was something unrelated to the hx-swap value which caused the above issue.

Since it's working now, I've changed it back to innerHTML in 5ed4c59.

@zandre-eng zandre-eng marked this pull request as ready for review February 13, 2025 08:54

def test_not_logged_in(self):
response = self._make_request(is_logged_in=False)
self.assertEqual(response.status_code, 404)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Now that we are using pytest, we can use Pythonic asserts.

Suggested change
self.assertEqual(response.status_code, 404)
assert response.status_code == 404

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've gone ahead and replaced most of the asserts in this test file with Pythonic asserts in fd522a5 (all apart from the self.assertRedirects one).

urlname = 'kyc_verify_table'
table_class = KycVerifyTable

def get_queryset(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I missed this on my first pass. Doesn't this need to return a QuerySet instance, like the method it overrides?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The docstring for the get_queryset function that this overrides states:

The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.

So it can be a QuerySet instance, but as long as it's an iterable then it's okay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product/feature-flag Change will only affect users who have a specific feature flag enabled
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants