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
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion corehq/apps/sms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1386,7 +1386,8 @@ def get_content_info_from_content_object(cls, domain, content):
EmailContent,
CustomContent,
FCMNotificationContent,
ConnectMessageContent
ConnectMessageContent,
ConnectMessageSurveyContent
)

if isinstance(content, (SMSContent, CustomContent)):
Expand All @@ -1401,6 +1402,8 @@ def get_content_info_from_content_object(cls, domain, content):
return cls.CONTENT_FCM_Notification, None, None, None
elif isinstance(content, ConnectMessageContent):
return cls.CONTENT_CONNECT, None, None, None
elif isinstance(content, ConnectMessageSurveyContent):
return cls.CONTENT_CONNECT, None, None, None
else:
return cls.CONTENT_NONE, None, None, None

Expand Down
11 changes: 11 additions & 0 deletions corehq/apps/sms/templates/sms/connect_messaging_users.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% extends 'hqwebapp/bootstrap3/base_section.html' %}
{% load i18n %}
{% load hq_shared_tags %}

{% block page_content %}
<div id="id_request" style="padding-bottom: 40px;" class="row">
<div class="col-xs-4">
<a class="btn btn-primary" href="{{ request_consent_url }}">{% trans "Request Messaging Consent" %}</a>
</div>
</div>
{% endblock %}
4 changes: 4 additions & 0 deletions corehq/apps/sms/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
ChatMessageHistory,
ChatOverSMSView,
ComposeMessageView,
ConnectMessagingUserView,
DomainSmsGatewayListView,
EditDomainGatewayView,
EditGlobalGatewayView,
Expand All @@ -20,6 +21,7 @@
api_send_sms,
chat,
chat_contact_list,
create_channels,
default,
download_sms_translations,
edit_sms_languages,
Expand Down Expand Up @@ -59,6 +61,8 @@
url(r'^translations/upload/$', upload_sms_translations, name='upload_sms_translations'),
url(r'^telerivet/', include(telerivet_urls)),
url(r'^whatsapp_templates/$', WhatsAppTemplatesView.as_view(), name=WhatsAppTemplatesView.urlname),
url(r'^connect_messaging_user/$', ConnectMessagingUserView.as_view(), name=ConnectMessagingUserView),
url(r'^create_channels/$', create_channels, name='create_channels'),
]


Expand Down
26 changes: 26 additions & 0 deletions corehq/apps/sms/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2059,3 +2059,29 @@ def page_context(self):
+ _(" failed to fetch templates. Please make sure the gateway is configured properly.")
)
return context


class ConnectMessagingUserView(BaseMessagingSectionView):
urlname = 'connect_messaging_user'
template_name = 'sms/connect_messaging_user.html'
page_title = _("Connect Messaging Users")

@method_decorator(domain_admin_required)
def dispatch(self, *args, **kwargs):
return super(ConnectMessagingUserView, self).dispatch(*args, **kwargs)

@property
def page_context(self):
page_context = super(ConnectMessagingUserView, self).page_context
page_context.update({
"create_channel_url": reverse(("create_channels", args=[self.domain]))
})


@domain_admin_required
def create_channels(self, request, *args, **kwargs):
user_links = ConnectIDUserLink.objects.filter(domain=request.domain)
backend = ConnectBackend()
for link in user_links:
backend.create_channel(link)
orangejenny marked this conversation as resolved.
Show resolved Hide resolved
return HttpResponseRedirect(reverse(ConnectMessagingUserView.urlname, args=[domain]))
11 changes: 11 additions & 0 deletions corehq/tabs/tabclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,17 @@ def whatsapp_urls(self):
})
return whatsapp_urls

@property
def connect_urls(self):
from corehq.apps.sms.views import ConnectMessagingUserView

connect_urls = []
if toggles.COMMCARE_CONNECT.enabled(self.domain):
connect_urls.append({
'title': _('User Consent'),
'url': reverse(ConnectMesssagingUserView.urlname, args=[self.domain]),
})

@property
def dropdown_items(self):
result = []
Expand Down