diff --git a/temba/campaigns/views.py b/temba/campaigns/views.py index 88adf8cc2f..7958e28dc7 100644 --- a/temba/campaigns/views.py +++ b/temba/campaigns/views.py @@ -67,6 +67,7 @@ def derive_menu(self): icon="campaign_archived", count=org.campaigns.filter(is_active=True, is_archived=True).count(), href="campaigns.campaign_archived", + perm="campaigns.campaign_list", ) ) @@ -162,27 +163,19 @@ def get_form_kwargs(self): return kwargs class BaseList(ContextMenuMixin, BulkActionMixin, BaseListView): + permission = "campaigns.campaign_list" fields = ("name", "group") default_template = "campaigns/campaign_list.html" default_order = ("-modified_on",) - def get_context_data(self, **kwargs): - context = super().get_context_data(**kwargs) - context["org_has_campaigns"] = self.request.org.campaigns.exists() - context["request_url"] = self.request.path - return context - class List(BaseList): title = _("Active") - fields = ("name", "group") bulk_actions = ("archive",) search_fields = ("name__icontains", "group__name__icontains") menu_path = "/campaign/active" def get_queryset(self, *args, **kwargs): - qs = super().get_queryset(*args, **kwargs) - qs = qs.filter(is_active=True, is_archived=False) - return qs + return super().get_queryset(*args, **kwargs).filter(is_archived=False) def build_context_menu(self, menu): if self.has_org_perm("campaigns.campaign_create"): @@ -196,14 +189,11 @@ def build_context_menu(self, menu): class Archived(BaseList): title = _("Archived") - fields = ("name",) bulk_actions = ("restore",) menu_path = "/campaign/archived" def get_queryset(self, *args, **kwargs): - qs = super().get_queryset(*args, **kwargs) - qs = qs.filter(is_active=True, is_archived=True) - return qs + return super().get_queryset(*args, **kwargs).filter(is_archived=True) class Archive(OrgObjPermsMixin, SmartUpdateView): fields = () diff --git a/temba/settings_common.py b/temba/settings_common.py index c333de375b..bd37922c43 100644 --- a/temba/settings_common.py +++ b/temba/settings_common.py @@ -343,7 +343,7 @@ ), "api.apitoken": ("explorer",), "archives.archive": ("run", "message"), - "campaigns.campaign": ("archived", "archive", "activate", "menu"), + "campaigns.campaign": ("archive", "activate", "menu"), "channels.channel": ("chart", "claim", "configuration", "errors", "facebook_whitelist"), "channels.channellog": ("connection",), "classifiers.classifier": ("connect", "sync"), @@ -595,7 +595,6 @@ "triggers.trigger.*", ), "Viewers": ( - "campaigns.campaign_archived", "campaigns.campaign_list", "campaigns.campaign_menu", "campaigns.campaign_read", diff --git a/templates/campaigns/campaign_list.html b/templates/campaigns/campaign_list.html index 01a1611b7b..08ec75bf0a 100644 --- a/templates/campaigns/campaign_list.html +++ b/templates/campaigns/campaign_list.html @@ -1,14 +1,38 @@ -{% extends "smartmin/list.html" %} -{% load smartmin sms temba compress i18n humanize %} +{% extends "orgs/base/list.html" %} +{% load i18n humanize %} -{% block extra-style %} - {{ block.super }} - -{% endblock extra-style %} +{% block table %} +
+ |
+ {% endif %}
+ {{ obj.name }} | +
+ {# in the past we let users delete groups used by campaigns #}
+ {% if obj.group.is_active %}
+ {% include "includes/recipients_group.html" with group=obj.group %}
+ {% endif %}
+ |
+ {{ obj.get_events|length }} event{{ obj.get_events|length|pluralize }} | +|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{% trans "No campaigns" %} | +
- |
- {% endif %}
- {{ obj.name }} | -
- {# in the past we let users delete groups used by campaigns #}
- {% if obj.group.is_active %}
- {% include "includes/recipients_group.html" with group=obj.group %}
- {% endif %}
- |
- {{ obj.get_events|length }} event{{ obj.get_events|length|pluralize }} | -|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{% trans "No campaigns" %} | -