WT-1281: More backend wiring for referral proj + dummy data generator#1637
Open
stevejalim wants to merge 3 commits into
Open
WT-1281: More backend wiring for referral proj + dummy data generator#1637stevejalim wants to merge 3 commits into
stevejalim wants to merge 3 commits into
Conversation
…th the Referral Hub page
…e code Note that if there is no ?ref_key in the URL opening the referral hub there will be no invitation link to share. This is because Referral Hub pages are not expected to be opened without a ref_key param - what the desired behaviour in that situation is TBC - we need to ask FX Referral team Key points: - Wire ReferralHubPage.get_context to build invite_url from ?ref_key= querystring - Add placeholder _referral_id_to_invite_code() helper - Empty invite_url when ref_key is missing/blank
Contributor
There was a problem hiding this comment.
Pull request overview
Adds local-development scaffolding for the Referral Hub feature so templates can be built and exercised against real-shaped data before the invite-code service is available.
Changes:
- Adds a
bootstrap_dummy_referral_datamanagement command to seed deterministic, TEST-prefixedFirefoxReferralDatarows and print local Hub URLs. - Updates
ReferralHubPage.get_context()to build aninvite_urlfrom?ref_key=...via a placeholder invite-code algorithm (and to return an empty invite_url when no ref_key is present). - Expands CMS tests to cover invite URL generation, empty ref_key behavior, and URL encoding.
Custom instructions note: This review was performed using the repository’s custom Copilot instructions (including AGENTS.md guidance).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| springfield/firefox/management/commands/bootstrap_dummy_referral_data.py | Adds a local-only seeding command for deterministic referral IDs and install counts. |
| springfield/firefox/management/commands/init.py | Introduces the commands package for Django management command discovery. |
| springfield/firefox/management/init.py | Introduces the management package for Django management command discovery. |
| springfield/cms/tests/test_referral_pages.py | Adds/updates tests for Referral Hub invite URL generation, missing/blank ref_key behavior, and encoding. |
| springfield/cms/models/pages.py | Adds placeholder invite-code generation and wires ref_key into invite_url creation in page context. |
Comment on lines
+2390
to
+2393
| if referral_id := request.GET.get("ref_key"): | ||
| invite_code = self._referral_id_to_invite_code(referral_id) | ||
| params = urlencode({"invitation": invite_code}) | ||
| context["invite_url"] = request.build_absolute_uri(f"/get-firefox/?{params}") |
Contributor
Author
There was a problem hiding this comment.
It won't affect attribution/querystrings.
Also, while the target page will be en-US only to start with, in the future it may be localized and this approach means the recipient of the link gets the best fit for their locale, not the invitER's locale
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds local-dev scaffolding for the Referral Hub page so the template can be built out against real-shaped data before the real invite-code service exists.
There's a new
bootstrap_dummy_referral_datamanagement command which generates 10 fake referral IDs /ref_keyvalues forFirefoxReferralDatarecords, with a range of install counts (0 → 4321). It prints the local Referral Hub URLs you can use to test withI've also updated
ReferralHubPage.get_contextto pull the?ref_key=<referral_id>off the request and use it to generate theinvite_urlusing a fake algorithm for now. Theinvite_urlis empty when noref_keyis present because the Referral Hub cannot generate a useful referral url, nor show stats. I'm checking in with @nathan-barrett to get confirmation of the ideal behaviour for these failure casses.Testing locally
ReferralHubPagelocally as a child of the homepage, with a slug ofinvite./manage.py bootstrap_dummy_referral_data, then load one of the printed URLs and confirm the Hub page renders its raw data, with aninvite_urlin there that ends withFAKE