From fe8186d9762301e717d23e05498ac922cea6cd48 Mon Sep 17 00:00:00 2001 From: Rowan Seymour Date: Fri, 5 Jul 2024 09:00:54 -0500 Subject: [PATCH] Change Channel.is_android to be a property to match Msg.is_android --- temba/api/v2/serializers.py | 2 +- temba/channels/models.py | 5 +++-- temba/channels/views.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/temba/api/v2/serializers.py b/temba/api/v2/serializers.py index aae29947425..85f24231066 100644 --- a/temba/api/v2/serializers.py +++ b/temba/api/v2/serializers.py @@ -471,7 +471,7 @@ def get_country(self, obj): return str(obj.country) if obj.country else None def get_device(self, obj): - if not obj.is_android(): + if not obj.is_android: return None return { diff --git a/temba/channels/models.py b/temba/channels/models.py index 036b5cd781c..f6a6c211a1f 100644 --- a/temba/channels/models.py +++ b/temba/channels/models.py @@ -510,6 +510,7 @@ def generate_secret(cls, length=64): code = generate_secret(length) return code + @property def is_android(self) -> bool: """ Is this an Android channel @@ -646,7 +647,7 @@ def release(self, user, *, trigger_sync: bool = True): self.save(update_fields=("is_active", "config", "modified_by", "modified_on")) # trigger the orphaned channel - if trigger_sync and self.is_android() and registration_id: + if trigger_sync and self.is_android and registration_id: self.trigger_sync(registration_id) # any triggers associated with our channel get archived and released @@ -679,7 +680,7 @@ def trigger_sync(self, registration_id=None): # pragma: no cover Sends a FCM command to trigger a sync on the client """ - assert self.is_android(), "can only trigger syncs on Android channels" + assert self.is_android, "can only trigger syncs on Android channels" from .tasks import sync_channel_fcm_task diff --git a/temba/channels/views.py b/temba/channels/views.py index e6559305bde..48a7563a7d1 100644 --- a/temba/channels/views.py +++ b/temba/channels/views.py @@ -524,7 +524,7 @@ def get_context_data(self, **kwargs): context["msg_count"] = channel.get_msg_count() context["ivr_count"] = channel.get_ivr_count() - if channel.is_android(): + if channel.is_android: context["latest_sync_events"] = channel.sync_events.order_by("-created_on")[:10] if not channel.is_new():