@property
    def page_context(self):
        # The webhook secret is a piece of data that is sent to hq on each
        # Telerivet inbound request. It's used to tie an inbound request to
        # a Telerivet backend.
        webhook_secret = uuid.uuid4().hex

        # The request token is only used for the purposes of using this UI to
        # setup a Telerivet backend. We need a way to post the webhook_secret
        # to create the backend, but we want hq to be the origin of the secret
        # generation. So instead, the request_token resolves to the webhook_secret
        # via a redis lookup which expires in 1 week.
        request_token = uuid.uuid4().hex

        self.set_cached_webhook_secret(request_token, webhook_secret)
        domain_has_default_gateway = SQLMobileBackend.get_domain_default_backend(
            SQLMobileBackend.SMS,
            self.domain,
            id_only=True
        ) is not None

        return {
            'outgoing_sms_form': TelerivetOutgoingSMSForm(),
            'test_sms_form': TelerivetPhoneNumberForm(),
            'finalize_gateway_form': FinalizeGatewaySetupForm(
                initial={
                    'set_as_default': (FinalizeGatewaySetupForm.NO
                                       if domain_has_default_gateway
                                       else FinalizeGatewaySetupForm.YES),
                }
            ),
            'webhook_url': absolute_reverse('telerivet_in'),
            'webhook_secret': webhook_secret,
            'request_token': request_token,
        }
dataset/ETHPy150Open dimagi/commcare-hq/corehq/messaging/smsbackends/telerivet/views.py/TelerivetSetupView.page_context/original