Skip to content

WT-1281: More backend wiring for referral proj + dummy data generator#1637

Open
stevejalim wants to merge 3 commits into
mainfrom
WT-1281--fxrefer-dev-data
Open

WT-1281: More backend wiring for referral proj + dummy data generator#1637
stevejalim wants to merge 3 commits into
mainfrom
WT-1281--fxrefer-dev-data

Conversation

@stevejalim

Copy link
Copy Markdown
Contributor

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_data management command which generates 10 fake referral IDs / ref_key values for FirefoxReferralData records, with a range of install counts (0 → 4321). It prints the local Referral Hub URLs you can use to test with

I've also updated ReferralHubPage.get_context to pull the ?ref_key=<referral_id> off the request and use it to generate the invite_url using a fake algorithm for now. The invite_url is empty when no ref_key is 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

  • Add a ReferralHubPage locally as a child of the homepage, with a slug of invite
  • run ./manage.py bootstrap_dummy_referral_data, then load one of the printed URLs and confirm the Hub page renders its raw data, with an invite_url in there that ends with FAKE

…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
@stevejalim
stevejalim requested a review from wen-2018 July 22, 2026 09:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_data management command to seed deterministic, TEST-prefixed FirefoxReferralData rows and print local Hub URLs.
  • Updates ReferralHubPage.get_context() to build an invite_url from ?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}")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Comment thread springfield/cms/models/pages.py
Comment thread springfield/cms/tests/test_referral_pages.py
Comment thread springfield/cms/tests/test_referral_pages.py
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.

2 participants