Skip to content

Commit

Permalink
Change Channel.is_android to be a property to match Msg.is_android
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Jul 5, 2024
1 parent 6524764 commit fe8186d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion temba/api/v2/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions temba/channels/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion temba/channels/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit fe8186d

Please sign in to comment.