Skip to content

Commit

Permalink
Simplify bulk labeling of msgs and flows
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Oct 17, 2024
1 parent 98fcf42 commit 6df195b
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 7 deletions.
3 changes: 0 additions & 3 deletions temba/contacts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,6 @@ def get_queryset(self, **kwargs):
patch_queryset_count(qs, self.group.get_member_count)
return qs

def get_bulk_action_labels(self):
return ContactGroup.get_groups(self.request.org, manual_only=True)

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)

Expand Down
3 changes: 1 addition & 2 deletions temba/flows/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,6 @@ class BaseList(BulkActionMixin, ContextMenuMixin, BaseListView):

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["labels"] = self.request.org.flow_labels.order_by(Lower("name"))

# decorate flow objects with their run activity stats
for flow in context["object_list"]:
Expand All @@ -701,7 +700,7 @@ def apply_bulk_action(self, user, action, objects, label):
)

def get_bulk_action_labels(self):
return self.request.org.flow_labels.filter(is_active=True)
return self.request.org.flow_labels.filter(is_active=True).order_by(Lower("name"))

def build_context_menu(self, menu):
if self.has_org_perm("flows.flow_create"):
Expand Down
3 changes: 1 addition & 2 deletions temba/msgs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,13 @@ def get_queryset(self, **kwargs):
return qs

def get_bulk_action_labels(self):
return self.request.org.msgs_labels.filter(is_active=True)
return self.request.org.msgs_labels.filter(is_active=True).order_by(Lower("name"))

def get_context_data(self, **kwargs):
org = self.request.org

context = super().get_context_data(**kwargs)
context["org"] = org
context["labels"] = Label.get_active_for_org(org).order_by(Lower("name"))

# if refresh was passed in, increase it by our normal refresh time
previous_refresh = self.request.GET.get("refresh")
Expand Down
1 change: 1 addition & 0 deletions temba/orgs/views/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ def post(self, request, *args, **kwargs):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["actions"] = self.get_bulk_actions()
context["labels"] = self.get_bulk_action_labels()
return context

def get_bulk_actions(self):
Expand Down

0 comments on commit 6df195b

Please sign in to comment.