Skip to content

Commit

Permalink
Merge branch 'main' into twilio-update
Browse files Browse the repository at this point in the history
  • Loading branch information
norkans7 authored Mar 8, 2023
2 parents 2bea8b5 + 02dcea8 commit 9e64f00
Show file tree
Hide file tree
Showing 21 changed files with 77 additions and 62 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
v8.1.62 (2023-03-08)
-------------------------
* Small z-index tweak

v8.1.61 (2023-03-07)
-------------------------
* Tweak simulator placement in new ui

v8.1.60 (2023-03-07)
-------------------------
* Encourage users to try the new interface
* Add lightbox for contact history

v8.1.59 (2023-03-07)
-------------------------
* Rework code depending on msg_type=I|F

v8.1.58 (2023-03-07)
-------------------------
* Add missing channels migration
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
]
},
"dependencies": {
"@nyaruka/flow-editor": "1.19.2",
"@nyaruka/temba-components": "0.42.1",
"@nyaruka/flow-editor": "1.19.3",
"@nyaruka/temba-components": "0.43.0",
"codemirror": "5.18.2",
"colorette": "1.2.2",
"fa-icons": "0.2.0",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "temba"
version = "8.1.58"
version = "8.1.62"
description = "Hosted service for visually building interactive messaging applications"
authors = ["Nyaruka <code@nyaruka.com>"]
license = "AGPL-3"
Expand Down
2 changes: 2 additions & 0 deletions static/css/temba-components.css
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ html {
--temba-charcount-summary-right: 0px;
--temba-charcount-summary-bottom: 0px;

--color-automated: rgb(78,205,106);

}

temba-button {
Expand Down
1 change: 1 addition & 0 deletions temba/campaigns/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def form_valid(self, form):

class Read(SpaMixin, OrgObjPermsMixin, ContentMenuMixin, SmartReadView):
slug_url_kwarg = "uuid"
menu_path = "/campaign/active"

def derive_title(self):
return self.object.name
Expand Down
8 changes: 4 additions & 4 deletions temba/channels/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,8 @@ def test_read(self):
self.tel_channel.save()

# now let's create an ivr interaction
self.create_incoming_msg(joe, "incoming ivr", channel=self.tel_channel, msg_type=Msg.TYPE_VOICE)
self.create_outgoing_msg(joe, "outgoing ivr", channel=self.tel_channel, msg_type=Msg.TYPE_VOICE)
self.create_incoming_msg(joe, "incoming ivr", channel=self.tel_channel, voice=True)
self.create_outgoing_msg(joe, "outgoing ivr", channel=self.tel_channel, voice=True)
response = self.fetch_protected(tel_channel_read_url, self.admin)

self.assertEqual(4, len(response.context["message_stats"]))
Expand Down Expand Up @@ -1567,15 +1567,15 @@ def test_daily_counts(self):
ChannelCount.objects.all().delete()

# incoming IVR
msg4 = self.create_incoming_msg(contact, "Test Message", msg_type=Msg.TYPE_VOICE)
msg4 = self.create_incoming_msg(contact, "Test Message", voice=True)
self.assertDailyCount(self.channel, 1, ChannelCount.INCOMING_IVR_TYPE, msg4.created_on.date())
msg4.delete()
self.assertDailyCount(self.channel, 1, ChannelCount.INCOMING_IVR_TYPE, msg4.created_on.date())

ChannelCount.objects.all().delete()

# outgoing ivr
msg5 = self.create_outgoing_msg(contact, "Real Voice", msg_type=Msg.TYPE_VOICE)
msg5 = self.create_outgoing_msg(contact, "Real Voice", voice=True)
self.assertDailyCount(self.channel, 1, ChannelCount.OUTGOING_IVR_TYPE, msg5.created_on.date())
msg5.delete()
self.assertDailyCount(self.channel, 1, ChannelCount.OUTGOING_IVR_TYPE, msg5.created_on.date())
Expand Down
5 changes: 4 additions & 1 deletion temba/contacts/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2505,10 +2505,13 @@ def test_history_templatetags(self):
item = {"type": "call_started", "status": "F"}
self.assertEqual(history_class(item), "non-msg warning")

# inbound
# inbound (legacy msg_type)
item = {"type": "msg_received", "msg": {"text": "Hi"}, "msg_type": "I"}
self.assertEqual(history_icon(item), '<span class="glyph icon-bubble-user"></span>')

item = {"type": "msg_received", "msg": {"text": "Hi"}, "msg_type": "T"}
self.assertEqual(history_icon(item), '<span class="glyph icon-bubble-user"></span>')

# outgoing sent
item = {"type": "msg_created", "msg": {"text": "Hi"}, "status": "S"}
self.assertEqual(history_icon(item), '<span class="glyph icon-bubble-right"></span>')
Expand Down
4 changes: 2 additions & 2 deletions temba/dashboard/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def create_activity(self):
self.create_outgoing_msg(joe, "Tea of coffee?")
self.create_incoming_msg(joe, "Coffee")
self.create_outgoing_msg(joe, "OK")
self.create_outgoing_msg(joe, "Wanna hang?", msg_type="V")
self.create_incoming_msg(joe, "Sure", msg_type="V")
self.create_outgoing_msg(joe, "Wanna hang?", voice=True)
self.create_incoming_msg(joe, "Sure", voice=True)

def test_dashboard_home(self):
dashboard_url = reverse("dashboard.dashboard_home")
Expand Down
2 changes: 1 addition & 1 deletion temba/mailroom/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def from_msg(cls, org: Org, user: User, obj: Msg) -> dict:
"created_on": get_event_time(obj).isoformat(),
"msg": _msg_in(obj),
# additional properties
"msg_type": obj.msg_type,
"msg_type": Msg.TYPE_VOICE if obj.msg_type == Msg.TYPE_VOICE else Msg.TYPE_TEXT,
"visibility": obj.visibility,
"logs_url": logs_url,
}
Expand Down
8 changes: 4 additions & 4 deletions temba/mailroom/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ def test_from_msg(self):
"channel": {"uuid": str(self.channel.uuid), "name": "Test Channel"},
"external_id": "12345",
},
"msg_type": "I",
"msg_type": "T",
"visibility": "V",
"logs_url": None,
},
Expand All @@ -826,7 +826,7 @@ def test_from_msg(self):
"channel": {"uuid": str(self.channel.uuid), "name": "Test Channel"},
"external_id": "12345",
},
"msg_type": "I",
"msg_type": "T",
"visibility": "D",
"logs_url": None,
},
Expand All @@ -849,7 +849,7 @@ def test_from_msg(self):
"channel": {"uuid": str(self.channel.uuid), "name": "Test Channel"},
"external_id": "12345",
},
"msg_type": "I",
"msg_type": "T",
"visibility": "X",
"logs_url": None,
},
Expand Down Expand Up @@ -919,7 +919,7 @@ def test_from_msg(self):
Event.from_msg(self.org, self.admin, msg_out),
)

ivr_out = self.create_outgoing_msg(contact1, "Hello", msg_type="V")
ivr_out = self.create_outgoing_msg(contact1, "Hello", voice=True)

self.assertEqual(
{
Expand Down
19 changes: 1 addition & 18 deletions temba/msgs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,23 +539,6 @@ class Msg(models.Model):
metadata = JSONAsTextField(null=True, default=dict)
log_uuids = ArrayField(models.UUIDField(), null=True)

@classmethod
def get_messages(cls, org, is_archived=False, direction=None, msg_type=None):
messages = cls.objects.filter(org=org)

if is_archived: # pragma: needs cover
messages = messages.filter(visibility=Msg.VISIBILITY_ARCHIVED)
else:
messages = messages.filter(visibility=Msg.VISIBILITY_VISIBLE)

if direction: # pragma: needs cover
messages = messages.filter(direction=direction)

if msg_type: # pragma: needs cover
messages = messages.filter(msg_type=msg_type)

return messages

@classmethod
def fail_old_messages(cls): # pragma: needs cover
"""
Expand Down Expand Up @@ -1181,7 +1164,7 @@ def _get_msg_batches(self, system_label, label, start_date, end_date):
elif label:
messages = label.get_messages()
else:
messages = Msg.get_messages(self.org)
messages = self.org.msgs.filter(visibility=Msg.VISIBILITY_VISIBLE)

messages = messages.filter(created_on__gte=start_date, created_on__lte=end_date)

Expand Down
2 changes: 1 addition & 1 deletion temba/msgs/templatetags/sms.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
def as_icon(contact_event):
icon = "icon-bubble-dots-2 green"
direction = getattr(contact_event, "direction", "O")
msg_type = getattr(contact_event, "msg_type", "I")
msg_type = getattr(contact_event, "msg_type", "T")

if hasattr(contact_event, "status"):
status = contact_event.status
Expand Down
5 changes: 3 additions & 2 deletions temba/msgs/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1329,7 +1329,7 @@ def test_big_ids(self):
text="Hi there",
channel=self.channel,
status="H",
msg_type="I",
msg_type="T",
visibility="V",
created_on=timezone.now(),
)
Expand Down Expand Up @@ -1630,6 +1630,7 @@ def test_failed(self, mock_msg_resend):
self.assertNotIn("resend", response.context["actions"])

def test_filter(self):
flow = self.create_flow("Flow")
joe = self.create_contact("Joe Blow", phone="+250788000001")
frank = self.create_contact("Frank Blow", phone="250788000002")
billy = self.create_contact("Billy Bob", urns=["twitter:billy_bob"])
Expand All @@ -1645,7 +1646,7 @@ def test_filter(self):
msg3 = self.create_incoming_msg(billy, "test3")
msg4 = self.create_incoming_msg(joe, "test4", visibility=Msg.VISIBILITY_ARCHIVED)
msg5 = self.create_incoming_msg(joe, "test5", visibility=Msg.VISIBILITY_DELETED_BY_USER)
msg6 = self.create_incoming_msg(joe, "flow test", msg_type="F")
msg6 = self.create_incoming_msg(joe, "IVR test", flow=flow)

# apply the labels
label1.toggle_label([msg1, msg2], add=True)
Expand Down
15 changes: 5 additions & 10 deletions temba/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,26 +288,21 @@ def create_incoming_msg(
contact,
text,
channel=None,
msg_type=None,
attachments=(),
status=Msg.STATUS_HANDLED,
visibility=Msg.VISIBILITY_VISIBLE,
created_on=None,
external_id=None,
voice=False,
surveyor=False,
flow=None,
):
assert not msg_type or status != Msg.STATUS_PENDING, "pending messages don't have a msg type"

if status == Msg.STATUS_HANDLED and not msg_type:
msg_type = Msg.TYPE_INBOX

return self._create_msg(
contact,
text,
Msg.DIRECTION_IN,
channel=channel,
msg_type=msg_type,
msg_type=Msg.TYPE_VOICE if voice else Msg.TYPE_TEXT,
attachments=attachments,
quick_replies=None,
status=status,
Expand All @@ -327,14 +322,14 @@ def create_outgoing_msg(
contact,
text,
channel=None,
msg_type=Msg.TYPE_TEXT,
attachments=(),
quick_replies=(),
status=Msg.STATUS_SENT,
created_on=None,
created_by=None,
sent_on=None,
high_priority=False,
voice=False,
surveyor=False,
next_attempt=None,
failed_reason=None,
Expand All @@ -352,7 +347,7 @@ def create_outgoing_msg(
text,
Msg.DIRECTION_OUT,
channel=channel,
msg_type=msg_type,
msg_type=Msg.TYPE_VOICE if voice else Msg.TYPE_TEXT,
attachments=attachments,
quick_replies=quick_replies,
status=status,
Expand Down Expand Up @@ -471,7 +466,7 @@ def create_broadcast(
text,
Msg.DIRECTION_OUT,
channel=None,
msg_type=Msg.TYPE_INBOX,
msg_type=Msg.TYPE_TEXT,
attachments=(),
quick_replies=(),
status=msg_status,
Expand Down
6 changes: 3 additions & 3 deletions temba/tests/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,12 @@ def _handle_msg_created(self, event):
contact=self.contact,
contact_urn=self.contact.get_urn(),
channel=Channel.objects.get(uuid=channel_ref["uuid"]) if channel_ref else None,
direction="O",
direction=Msg.DIRECTION_OUT,
text=event["msg"]["text"],
attachments=attachments,
created_on=event["created_on"],
msg_type="F",
status="S",
msg_type=Msg.TYPE_TEXT,
status=Msg.STATUS_SENT,
sent_on=event["created_on"],
)

Expand Down
6 changes: 3 additions & 3 deletions temba/tickets/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def assert_tickets(resp, tickets: list):
"last_msg": {
"text": "Hello?",
"direction": "I",
"type": "I",
"type": "T",
"created_on": matchers.ISODate(),
"sender": None,
"attachments": [],
Expand All @@ -370,7 +370,7 @@ def assert_tickets(resp, tickets: list):
"last_msg": {
"text": "We can help",
"direction": "O",
"type": "I",
"type": "T",
"created_on": matchers.ISODate(),
"sender": {"id": self.admin.id, "email": "admin@nyaruka.com"},
"attachments": [],
Expand All @@ -391,7 +391,7 @@ def assert_tickets(resp, tickets: list):
"last_msg": {
"text": "We can help",
"direction": "O",
"type": "I",
"type": "T",
"created_on": matchers.ISODate(),
"sender": {"id": self.admin.id, "email": "admin@nyaruka.com"},
"attachments": [],
Expand Down
8 changes: 8 additions & 0 deletions templates/flows/flow_editor_spa.haml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@
height: 100%;
}

.simulator {
top: 59px !important;
}

.revisions {
top: 110px !important;
}

#simulator-tab {
margin-right: 17px;
}
Expand Down
3 changes: 3 additions & 0 deletions templates/orgs/login/login.haml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

{% analytics_hook 'login' %}

:javascript
document.cookie = "nav=2; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/;";

-blocktrans trimmed
Please sign in with your email address and password.

Expand Down
4 changes: 3 additions & 1 deletion templates/spa_frame.haml
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@
.flex-grow

.folders
%temba-menu#nav(class="{% if servicing %}{% endif%}" style="height:100%" endpoint="{% url 'orgs.org_menu' %}" onchange="handleMenuChanged(event)" -temba-button-clicked="handleMenuClicked(event)" -temba-ready="handleMenuReady")
%temba-menu.relative.z-0#nav(class="{% if servicing %}{% endif%}" style="height:100%" endpoint="{% url 'orgs.org_menu' %}" onchange="handleMenuChanged(event)" -temba-button-clicked="handleMenuClicked(event)" -temba-ready="handleMenuReady")
-block menu-header

.flex-grow.spa-container.flex.flex-col.initial-load
Expand Down Expand Up @@ -782,3 +782,5 @@
Go back to the
%span.linked(onclick="leaveNewInterface()" style="color:#43b1ff")<
old interface

%temba-lightbox
2 changes: 1 addition & 1 deletion templates/tickets/ticket_list_spa.haml
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,4 @@
Sometimes an automated chatbot isn't enough. When your contacts need to chat with a real person, you can use the
Open Ticket action to open a new ticket.

%temba-contact-chat.shadow(agent="{{request.user.email}}" -temba-refreshed="handleContactHistoryUpdated" -temba-content-changed="handleTicketUpdated" monitor="true" toolbar="true")
%temba-contact-chat.shadow.mb-6(agent="{{request.user.email}}" -temba-refreshed="handleContactHistoryUpdated" -temba-content-changed="handleTicketUpdated" monitor="true" toolbar="true")
Loading

0 comments on commit 9e64f00

Please sign in to comment.