diff --git a/temba/channels/types/firebase/tests.py b/temba/channels/types/firebase/tests.py index badce95441..d62c22bc51 100644 --- a/temba/channels/types/firebase/tests.py +++ b/temba/channels/types/firebase/tests.py @@ -20,7 +20,7 @@ def setUp(self): address="87654", role="SR", schemes=["fcm"], - config={"FCM_TITLE": "Title", "FCM_AUTH_JSON": {"foo": "bar", "project_id": "87654"}}, + config={"FCM_TITLE": "Title", "FCM_CREDENTIALS_JSON": {"foo": "bar", "project_id": "87654"}}, ) @patch("requests.get") @@ -50,7 +50,7 @@ def test_claim(self, mock_get): self.assertEqual( channel.config, { - "FCM_AUTH_JSON": {"foo": "bar", "baz": "abc", "project_id": "abcde12345"}, + "FCM_CREDENTIALS_JSON": {"foo": "bar", "baz": "abc", "project_id": "abcde12345"}, "FCM_TITLE": "FCM Channel", "FCM_NOTIFICATION": True, }, diff --git a/temba/channels/types/firebase/views.py b/temba/channels/types/firebase/views.py index e16e443487..b9f48eedd5 100644 --- a/temba/channels/types/firebase/views.py +++ b/temba/channels/types/firebase/views.py @@ -1,21 +1,14 @@ -import json - from smartmin.views import SmartFormView from django import forms from django.utils.translation import gettext_lazy as _ -from temba.utils.fields import InputWidget +from temba.utils.fields import InputWidget, PrettyJSONEncoder from ...models import Channel from ...views import ClaimViewMixin -class PrettyJSONEncoder(json.JSONEncoder): - def __init__(self, *args, indent, sort_keys, **kwargs): - super().__init__(*args, indent=4, sort_keys=False, **kwargs) - - class ClaimView(ClaimViewMixin, SmartFormView): class Form(ClaimViewMixin.Form): title = forms.CharField(label=_("Notification Title")) @@ -43,7 +36,7 @@ def form_valid(self, form): title = form.cleaned_data.get("title") authentication_json = form.cleaned_data.get("authentication_json") address = form.cleaned_data.get("address") - config = {"FCM_TITLE": title, "FCM_AUTH_JSON": authentication_json} + config = {"FCM_TITLE": title, "FCM_CREDENTIALS_JSON": authentication_json} if form.cleaned_data.get("send_notification") == "True": config["FCM_NOTIFICATION"] = True diff --git a/temba/utils/fields.py b/temba/utils/fields.py index ba76e621d0..a4c960c38a 100644 --- a/temba/utils/fields.py +++ b/temba/utils/fields.py @@ -387,3 +387,8 @@ def prepare_value(self, value): def valid_value(self, value): return True + + +class PrettyJSONEncoder(json.JSONEncoder): # pragma: needs cover + def __init__(self, *args, indent, sort_keys, **kwargs): + super().__init__(*args, indent=4, sort_keys=False, **kwargs)