Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ce/connect messaging #35364

Open
wants to merge 57 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
0043322
add models and rename function
calellowitz Nov 14, 2024
7bc3854
add connect backend
calellowitz Nov 14, 2024
c609f0d
add connectid settings and urls
calellowitz Nov 14, 2024
e4b6deb
add connect messages to scheduling forms
calellowitz Nov 14, 2024
929204d
add necessary auth changes
calellowitz Nov 14, 2024
79154f0
update domain deletion code for new models
calellowitz Nov 14, 2024
460c794
use updated method name
calellowitz Nov 14, 2024
092dbe0
implement survey model
calellowitz Nov 15, 2024
f29ebfc
fix default values
calellowitz Nov 15, 2024
91ce6e6
move content fields to top level of payload
calellowitz Nov 22, 2024
4b992c7
use string for the key
calellowitz Nov 26, 2024
36a800f
return the value
calellowitz Nov 26, 2024
472609a
typo
calellowitz Nov 26, 2024
1efd62e
incoming messaging processing updates
calellowitz Nov 27, 2024
80e0345
handle connect content
calellowitz Nov 27, 2024
f327d55
add create channel views
calellowitz Nov 28, 2024
6d9e562
add connect survey content
calellowitz Nov 28, 2024
8421124
update models for connect message survey
calellowitz Nov 28, 2024
e725557
return context
calellowitz Nov 28, 2024
a9b2f08
correct template name
calellowitz Nov 28, 2024
d5935d2
use correct context name
calellowitz Nov 28, 2024
7a59b8e
add imports
calellowitz Nov 28, 2024
ef87ae1
update view args
calellowitz Nov 28, 2024
7680272
handle incorrect username
calellowitz Dec 1, 2024
921d8be
add urls to sidebar
calellowitz Dec 2, 2024
70bce3c
require toggle
calellowitz Dec 3, 2024
a3b39ff
fix f strings
calellowitz Dec 4, 2024
f1a02f8
fix typo in view name
calellowitz Dec 4, 2024
7be46a3
Update corehq/messaging/scheduling/forms.py
calellowitz Dec 5, 2024
370bab0
use message instead of payload dict
calellowitz Dec 9, 2024
d869378
Merge branch 'master' into ce/connect-messaging
orangejenny Dec 10, 2024
63f9b29
return url list
calellowitz Dec 12, 2024
5b85e3f
fix auth and pull out key generation
calellowitz Dec 12, 2024
11a6e7f
create key on sending first message if not created yet
calellowitz Dec 12, 2024
00fd753
add missing imports
calellowitz Dec 13, 2024
e810011
fix typo in form initial values
calellowitz Dec 13, 2024
2c5b5fc
set message id on init
calellowitz Dec 13, 2024
5de9a9f
missing import and definition
calellowitz Dec 17, 2024
0231864
use domain instead of domain_scope
calellowitz Dec 19, 2024
596eba4
fix function error
calellowitz Dec 19, 2024
0fa683e
pr feedback and report error
calellowitz Dec 19, 2024
c67ac9e
update report
calellowitz Dec 19, 2024
10737b7
lint
calellowitz Dec 19, 2024
8dd41f1
convert to f strings
calellowitz Dec 19, 2024
a66ec40
move copy and lint
calellowitz Dec 19, 2024
c047e8e
move critical section to base class
calellowitz Dec 19, 2024
75184ce
make try block narrower
calellowitz Dec 19, 2024
7d66924
add success message to channel creation
calellowitz Dec 19, 2024
b652ddb
replace get_sms_class
calellowitz Dec 19, 2024
b28cdbf
update sms docs
calellowitz Dec 19, 2024
867dd47
Merge branch 'master' into ce/connect-messaging
calellowitz Dec 19, 2024
f50e557
fix bad merge
calellowitz Dec 19, 2024
eccc425
squash migrations
calellowitz Dec 19, 2024
ae2d380
replace method with property
calellowitz Dec 19, 2024
aaffbaa
add new models to domain deletion and dump
calellowitz Dec 19, 2024
7142730
add more models to domain deletion
calellowitz Dec 19, 2024
599af78
fix bug in channel creation and improve message
calellowitz Dec 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion corehq/apps/reports/standard/sms.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
OUTGOING,
SMS,
WORKFLOWS_FOR_REPORTS,
ConnectMessage,
MessagingEvent,
MessagingSubEvent,
PhoneBlacklist,
Expand Down Expand Up @@ -709,8 +710,8 @@
event_status = EventStatusFilter.get_value(self.request, self.domain)
if event_status == MessagingEvent.STATUS_ERROR:
event_status_filter = (
Q(status=event_status) |

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

View workflow job for this annotation

GitHub Actions / Flake8

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

Line break after binary operator (W504)
Q(messagingsubevent__status=event_status) |

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

View workflow job for this annotation

GitHub Actions / Flake8

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

Line break after binary operator (W504)
Q(messagingsubevent__sms__error=True)
)
elif event_status == MessagingEvent.STATUS_IN_PROGRESS:
Expand All @@ -720,21 +721,21 @@
# session_is_open=True if there actually are
# subevent and xforms session records
event_status_filter = (
Q(status=event_status) |

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

View workflow job for this annotation

GitHub Actions / Flake8

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

Line break after binary operator (W504)
Q(messagingsubevent__status=event_status) |

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

View workflow job for this annotation

GitHub Actions / Flake8

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

Line break after binary operator (W504)
(Q(messagingsubevent__xforms_session__id__isnull=False) &

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

View workflow job for this annotation

GitHub Actions / Flake8

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

Line break after binary operator (W504)
Q(messagingsubevent__xforms_session__session_is_open=True))
)
elif event_status == MessagingEvent.STATUS_NOT_COMPLETED:
event_status_filter = (
Q(status=event_status) |

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

View workflow job for this annotation

GitHub Actions / Flake8

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

Line break after binary operator (W504)
Q(messagingsubevent__status=event_status) |

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

View workflow job for this annotation

GitHub Actions / Flake8

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

Line break after binary operator (W504)
(Q(messagingsubevent__xforms_session__session_is_open=False) &

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

View workflow job for this annotation

GitHub Actions / Flake8

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

Line break after binary operator (W504)
Q(messagingsubevent__xforms_session__submission_id__isnull=True))
)
elif event_status == MessagingEvent.STATUS_EMAIL_DELIVERED:
event_status_filter = (
Q(status=event_status) |

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

View workflow job for this annotation

GitHub Actions / Flake8

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

Line break after binary operator (W504)
Q(messagingsubevent__status=event_status)
)

Expand Down Expand Up @@ -773,7 +774,7 @@

if content_type_filter:
data = data.filter(
(Q(content_type__in=content_type_filter) |

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

View workflow job for this annotation

GitHub Actions / Flake8

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

Line break after binary operator (W504)
Q(messagingsubevent__content_type__in=content_type_filter))
)

Expand Down Expand Up @@ -873,7 +874,7 @@
if self.messaging_event:
if self.messaging_event.content_type == MessagingEvent.CONTENT_EMAIL:
contact_column = EMAIL_ADDRRESS
elif self.messaging_event.content_type in (MessagingEvent.CONTENT_CONNECT, MessagingEvent.CONTENT_CONNECT_SURVEY):

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

View workflow job for this annotation

GitHub Actions / Flake8

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

Line too long (126 > 115 characters) (E501)
contact_column = CONNECT_ID
else:
contact_column = PHONE_NUMBER
Expand Down Expand Up @@ -915,10 +916,10 @@
def view_response(self):
subevents = self.messaging_subevents
if (
len(subevents) == 1 and

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

View workflow job for this annotation

GitHub Actions / Flake8

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

Line break after binary operator (W504)
subevents[0].content_type in (MessagingEvent.CONTENT_SMS_SURVEY,
MessagingEvent.CONTENT_IVR_SURVEY) and

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

View workflow job for this annotation

GitHub Actions / Flake8

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

Line break after binary operator (W504)
subevents[0].xforms_session_id and

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

View workflow job for this annotation

GitHub Actions / Flake8

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

Line break after binary operator (W504)
subevents[0].status != MessagingEvent.STATUS_ERROR
):
# There's only one survey to report on here - just redirect to the
Expand Down Expand Up @@ -964,7 +965,8 @@
self._fmt(status),
])
elif messaging_subevent.content_type in (MessagingEvent.CONTENT_SMS_SURVEY,
MessagingEvent.CONTENT_IVR_SURVEY):
MessagingEvent.CONTENT_IVR_SURVEY,
MessagingEvent.CONTENT_CONNECT_SURVEY):
status = get_status_display(messaging_subevent)
xforms_session = messaging_subevent.xforms_session
timestamp = xforms_session.start_time if xforms_session else messaging_subevent.date
Expand Down Expand Up @@ -998,6 +1000,26 @@
self._fmt(_('Email')),
self._fmt(status),
])
elif messaging_subevent.content_type == MessagingEvent.CONTENT_CONNECT:
timestamp = ServerTime(messaging_subevent.date).user_time(self.timezone).done()
status = get_status_display(messaging_subevent)
content = '-'
recipient_address = '-'
try:
msg = ConnectMessage.objects.get(messaging_subevent=messaging_subevent.pk)
content = msg.text
orangejenny marked this conversation as resolved.
Show resolved Hide resolved
recipient = msg.couch_recipient
except ConnectMessage.DoesNotExist:
pass
result.append([
self._fmt_timestamp(timestamp),
self._fmt_contact_link(messaging_subevent.recipient_id, doc_info),
self._fmt(content),
self._fmt(recipient),
self._fmt_direction(msg.direction),
self._fmt(_('Connect Message')),
self._fmt(status),
])
return result


Expand Down Expand Up @@ -1209,8 +1231,8 @@
@property
def _show_users_without_phone_numbers(self):
return (
self.filter_type == 'contact' and

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

View workflow job for this annotation

GitHub Actions / Flake8

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

Line break after binary operator (W504)
self.contact_type == 'users' and

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

View workflow job for this annotation

GitHub Actions / Flake8

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

Line break after binary operator (W504)
self.has_phone_number != 'has_phone_number'
)

Expand All @@ -1233,9 +1255,9 @@
elif number.pending_verification:
return "Verification Pending"
elif (
not (number.is_two_way or number.pending_verification) and

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

View workflow job for this annotation

GitHub Actions / Flake8

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

Line break after binary operator (W504)
PhoneNumber.get_reserved_number(number.phone_number)
):

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

View workflow job for this annotation

GitHub Actions / Flake8

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

Continuation line over-indented for hanging indent (E126)
return "Already In Use"
return "Not Verified"

Expand Down
Loading