Skip to content

Commit

Permalink
pr feedback and report error
Browse files Browse the repository at this point in the history
  • Loading branch information
calellowitz committed Dec 19, 2024
1 parent 596eba4 commit 0fa683e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 30 deletions.
2 changes: 1 addition & 1 deletion corehq/apps/reports/standard/sms.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ def headers(self):
if self.messaging_event:
if self.messaging_event.content_type == MessagingEvent.CONTENT_EMAIL:
contact_column = EMAIL_ADDRRESS
elif self.messaging_event.content_type == MessagingEvent.CONTENT_CONNECT:
elif self.messaging_event.content_type in (MessagingEvent.CONTENT_CONNECT, MessagingEvent.CONTENT_CONNECT_SURVEY):

Check failure on line 876 in corehq/apps/reports/standard/sms.py

View workflow job for this annotation

GitHub Actions / Flake8

corehq/apps/reports/standard/sms.py#L876

Line too long (126 > 115 characters) (E501)
contact_column = CONNECT_ID
else:
contact_column = PHONE_NUMBER
Expand Down
32 changes: 5 additions & 27 deletions corehq/apps/sms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,39 +596,21 @@ def opt_out_sms(cls, phone_number, domain=None):
return True


class AbstractNumber(ABC):
owner_doc_type = None
owner_id = None
is_two_way = None
phone_number = None
domain = None

@property
@abstractmethod
def backend(self):
pass

@property
@abstractmethod
def is_sms(self):
pass


class ConnectMessagingNumber(AbstractNumber):
class ConnectMessagingNumber:
owner_doc_type = "CommCareUser"
is_two_way = True
pending_verification = False

def __init__(self, user):
self.user = user
def __init__(self, owner):
self.owner = owner

@property
def phone_number(self):
return self.user_link.channel_id

@property
def user_link(self):
django_user = self.user.get_django_user()
django_user = self.owner.get_django_user()
return ConnectIDUserLink.objects.get(commcare_user=django_user)

@property
Expand All @@ -637,11 +619,7 @@ def backend(self):

@property
def owner_id(self):
return self.user._id

@property
def owner(self):
return self.user
return self.owner._id

@property
def domain(self):
Expand Down
2 changes: 1 addition & 1 deletion corehq/apps/smsforms/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def send_first_message(domain, recipient, phone_entry_or_number, session, respon
messaging_subevent_id=logged_subevent.pk
)

if isinstance(phone_entry_or_number, PhoneNumber) or isinstance(phone_entry_or_number, ConnectMessagingNumber):
if isinstance(phone_entry_or_number, (PhoneNumber, ConnectMessagingNumber)):
send_message_to_verified_number(
phone_entry_or_number,
message,
Expand Down
2 changes: 1 addition & 1 deletion corehq/messaging/scheduling/models/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def memoized_language_set(self):
content = event.memoized_content
if isinstance(content, (SMSContent, SMSCallbackContent, ConnectMessageContent)):
result |= set(content.message)
elif isinstance(content, (EmailContent)):
elif isinstance(content, EmailContent):
result |= set(content.subject)
result |= set(content.message)

Expand Down

0 comments on commit 0fa683e

Please sign in to comment.