Skip to content

Commit

Permalink
Merge pull request #5589 from nyaruka/contact_group_read_tweak
Browse files Browse the repository at this point in the history
Tweak name/url of contact group filter list page
  • Loading branch information
rowanseymour authored Oct 28, 2024
2 parents 6a9ab05 + 84d5dc8 commit d3b0b6e
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 29 deletions.
14 changes: 7 additions & 7 deletions temba/contacts/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def test_archived(self, mr_mocks):
self.assertEqual(0, len(response.context["object_list"]))

@mock_mailroom
def test_filter(self, mr_mocks):
def test_group(self, mr_mocks):
open_tickets = self.org.groups.get(name="Open Tickets")
joe = self.create_contact("Joe", phone="123")
frank = self.create_contact("Frank", phone="124")
Expand All @@ -416,10 +416,10 @@ def test_filter(self, mr_mocks):
group2.contacts.add(frank)
group3 = self.create_group("Other Org", org=self.org2)

group1_url = reverse("contacts.contact_filter", args=[group1.uuid])
group2_url = reverse("contacts.contact_filter", args=[group2.uuid])
group3_url = reverse("contacts.contact_filter", args=[group3.uuid])
open_tickets_url = reverse("contacts.contact_filter", args=[open_tickets.uuid])
group1_url = reverse("contacts.contact_group", args=[group1.uuid])
group2_url = reverse("contacts.contact_group", args=[group2.uuid])
group3_url = reverse("contacts.contact_group", args=[group3.uuid])
open_tickets_url = reverse("contacts.contact_group", args=[open_tickets.uuid])

self.assertRequestDisallowed(group1_url, [None, self.agent, self.admin2])
response = self.assertReadFetch(group1_url, [self.user, self.editor, self.admin])
Expand Down Expand Up @@ -447,7 +447,7 @@ def test_filter(self, mr_mocks):
self.assertContentMenu(open_tickets_url, self.admin, ["Export", "Usages"])

# if a user tries to access a non-existent group, that's a 404
response = self.requestView(reverse("contacts.contact_filter", args=["21343253"]), self.admin)
response = self.requestView(reverse("contacts.contact_group", args=["21343253"]), self.admin)
self.assertEqual(404, response.status_code)

# if a user tries to access a group in another org, send them to the login page
Expand Down Expand Up @@ -1087,7 +1087,7 @@ def test_create_smart(self, mr_mocks):

# dynamic group should not have remove to group button
self.login(self.admin)
filter_url = reverse("contacts.contact_filter", args=[group.uuid])
filter_url = reverse("contacts.contact_group", args=[group.uuid])
self.client.get(filter_url)

# put group back into evaluation state
Expand Down
14 changes: 7 additions & 7 deletions temba/contacts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class ContactCRUDL(SmartCRUDL):
"list",
"menu",
"read",
"filter",
"group",
"blocked",
"omnibox",
"open_ticket",
Expand Down Expand Up @@ -257,7 +257,7 @@ def render_to_response(self, context, **response_kwargs):
name=g.name,
icon=g.icon,
count=group_counts[g],
href=reverse("contacts.contact_filter", args=[g.uuid]),
href=reverse("contacts.contact_group", args=[g.uuid]),
)
)

Expand Down Expand Up @@ -600,8 +600,8 @@ def build_context_menu(self, menu):
if self.has_org_perm("contacts.contact_delete"):
menu.add_js("contacts_delete_all", _("Delete All"))

class Filter(OrgObjPermsMixin, ContextMenuMixin, ContactListView):
template_name = "contacts/contact_filter.html"
class Group(OrgObjPermsMixin, ContextMenuMixin, ContactListView):
template_name = "contacts/contact_group.html"

def build_context_menu(self, menu):
if not self.group.is_system and self.has_org_perm("contacts.contactgroup_update"):
Expand Down Expand Up @@ -843,7 +843,7 @@ class ContactGroupCRUDL(SmartCRUDL):
class Create(ComponentFormMixin, ModalFormMixin, OrgPermsMixin, SmartCreateView):
form_class = ContactGroupForm
fields = ("name", "preselected_contacts", "group_query")
success_url = "uuid@contacts.contact_filter"
success_url = "uuid@contacts.contact_group"
submit_button_name = _("Create")

def save(self, obj):
Expand Down Expand Up @@ -877,7 +877,7 @@ def get_form_kwargs(self):
class Update(ComponentFormMixin, ModalFormMixin, OrgObjPermsMixin, SmartUpdateView):
form_class = ContactGroupForm
fields = ("name",)
success_url = "uuid@contacts.contact_filter"
success_url = "uuid@contacts.contact_group"

def get_queryset(self):
return super().get_queryset().filter(is_system=False)
Expand Down Expand Up @@ -906,7 +906,7 @@ class Usages(BaseUsagesModal):
permission = "contacts.contactgroup_read"

class Delete(BaseDependencyDeleteModal):
cancel_url = "uuid@contacts.contact_filter"
cancel_url = "uuid@contacts.contact_group"
success_url = "@contacts.contact_list"


Expand Down
10 changes: 1 addition & 9 deletions temba/settings_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,15 +347,7 @@
"channels.channel": ("chart", "claim", "configuration", "errors", "facebook_whitelist"),
"channels.channellog": ("connection",),
"classifiers.classifier": ("connect", "sync"),
"contacts.contact": (
"export",
"history",
"interrupt",
"menu",
"omnibox",
"open_ticket",
"start",
),
"contacts.contact": ("export", "history", "interrupt", "menu", "omnibox", "open_ticket", "start"),
"contacts.contactfield": ("update_priority",),
"contacts.contactgroup": ("menu",),
"contacts.contactimport": ("preview",),
Expand Down
2 changes: 1 addition & 1 deletion temba/utils/templatetags/temba.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
Flow: lambda o: reverse("flows.flow_editor", args=[o.uuid]),
Campaign: lambda o: reverse("campaigns.campaign_read", args=[o.uuid]),
CampaignEvent: lambda o: reverse("campaigns.campaign_read", args=[o.uuid]),
ContactGroup: lambda o: reverse("contacts.contact_filter", args=[o.uuid]),
ContactGroup: lambda o: reverse("contacts.contact_group", args=[o.uuid]),
Trigger: lambda o: reverse("triggers.trigger_list"),
}

Expand Down
2 changes: 1 addition & 1 deletion temba/utils/templatetags/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def test_object_url(self):
group = self.create_group("Testers", contacts=[])

self.assertEqual(f"/flow/editor/{flow.uuid}/", tags.object_url(flow))
self.assertEqual(f"/contact/filter/{group.uuid}/", tags.object_url(group))
self.assertEqual(f"/contact/group/{group.uuid}/", tags.object_url(group))

def test_object_class_plural(self):
self.assertEqual("Flow", tags.object_class_name(Flow()))
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion templates/contacts/contact_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
{% for group in object.all_groups.all %}
{% if group.group_type == 'U' %}
<span data-id="{{ group.id }}" class="label label-info lbl">
<a href="{% url 'contacts.contact_filter' group.uuid %}">{{ group.name }}</a>
<a href="{% url 'contacts.contact_group' group.uuid %}">{{ group.name }}</a>
</span>
{% endif %}
{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion templates/contacts/contactimport_read.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<div class="import-result text-lg mt-2">
<temba-icon name="check" class="text-success mr-2">
</temba-icon>
{% url 'contacts.contact_filter' object.group.uuid as group_url %}
{% url 'contacts.contact_group' object.group.uuid as group_url %}
{% blocktrans trimmed count info.num_created|add:info.num_updated as count with group_url=group_url group_name=object.group.name %}
Added {{ count }} contact to the <span class="linked" onclick="goto(event)" href="{{ group_url }}">{{ group_name }}</span> group
{% plural %}
Expand Down
2 changes: 1 addition & 1 deletion templates/contacts/export_download.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<th>{% trans "Group" %}</th>
<td>
{% if group.group_type == "M" or group.group_type == "S" %}
<a href="{% url "contacts.contact_filter" group.uuid %}">{{ group.name }}</a>
<a href="{% url "contacts.contact_group" group.uuid %}">{{ group.name }}</a>
{% else %}
{{ group.name }}
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion templates/includes/recipients_group.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{# djlint:off #}
<a href="{% url 'contacts.contact_filter' group.uuid %}" onclick="goto(event, this)"><temba-label icon="group{% if groups_as_filters %}{% if exclusion %}_exclude{% else %}_include{% endif %}{% endif %}" clickable class="mr-1 mb-1">{{ group.name }}</temba-label></a>
<a href="{% url 'contacts.contact_group' group.uuid %}" onclick="goto(event, this)"><temba-label icon="group{% if groups_as_filters %}{% if exclusion %}_exclude{% else %}_include{% endif %}{% endif %}" clickable class="mr-1 mb-1">{{ group.name }}</temba-label></a>
{# djlint:on #}

0 comments on commit d3b0b6e

Please sign in to comment.