Skip to content

Commit

Permalink
Allow to send/discard filtered outbox list
Browse files Browse the repository at this point in the history
  • Loading branch information
rixx committed Nov 14, 2024
1 parent f3b8585 commit 05e3773
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 24 deletions.
1 change: 1 addition & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Release Notes
=============

- :feature:`orga` You can now send or discard only a filtered list of emails from the outbox.
- :feature:`dev,1596` With the new ``queuedmail_pre_send`` signal, your plugin can modify a `QueuedMail` object before it is sent out. You can handle the sending entirely by setting the object’s `sent` attribute, or e.g. modify the email text before it is sent out by pretalx.
- :feature:`orga` Outgoing mails now know which proposals or sessions they are about. This information can’t be added to existing mails, but will be included in all new mails, which will link to the proposals in question, and will help you find relevant emails by showing the linked proposals and their track colours (if any).
- :feature:`orga:schedule` When exporting your sessions or submissions as CSV or JSON, you can now choose to export start and end times as separate date/time values instead of a single combined value.
Expand Down
38 changes: 24 additions & 14 deletions src/pretalx/orga/templates/orga/mails/outbox_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,32 @@ <h2>
</span>
</h2>
<div class="submit-group">
<span>
<div>
{% include "common/includes/search_form.html" with omit_wrapper=True %}
</span>
<span>
{% if is_paginated and page_obj.paginator.num_pages > 1 %}
<a href="{{ request.event.orga_urls.send_outbox }}?pks={% for mail in mails %}{{ mail.pk }}{% if not forloop.last %},{% endif %}{% endfor %}">
<button class="btn btn-outline-success">{% translate "Send all on this page" %}</button>
</div>
<div class="d-flex flex-column align-items-end">
<div>
{% if is_paginated and page_obj.paginator.num_pages > 1 %}
<a href="{{ request.event.orga_urls.send_outbox }}?pks={% for mail in mails %}{{ mail.pk }}{% if not forloop.last %},{% endif %}{% endfor %}">
<button class="btn btn-outline-success">{% translate "Send all on this page" %}</button>
</a>
{% endif %}
<a href="{{ request.event.orga_urls.send_outbox }}?{{ request.GET.urlencode }}" class="btn btn-success">
{% translate "Send all" %}
</a>
{% endif %}
<a href="{{ request.event.orga_urls.send_outbox }}">
<button class="btn btn-success">{% translate "Send all" %}</button>
</a>
<a href="{{ request.event.orga_urls.purge_outbox }}">
<button class="btn btn-danger">{% translate "Discard all" %}</button>
</a>
</span>
<a href="{{ request.event.orga_urls.purge_outbox }}?{{ request.GET.urlencode }}" class="btn btn-danger">
{% translate "Discard all" %}
</a>
</div>
<div>
{% if is_filtered %}
<div class="text-right text-muted mt-2">
<i class="fa fa-filter"></i>
{% translate "The current filters will be used when sending/discarding emails." %}
</div>
{% endif %}
</div>
</div>
</div>
<div class="table-responsive-sm">
<table class="table table-sm table-hover table-flip table-sticky">
Expand Down
25 changes: 15 additions & 10 deletions src/pretalx/orga/views/mails.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ def get_queryset(self):
def show_tracks(self):
return self.request.event.get_feature_flag("use_tracks")

@context
@cached_property
def is_filtered(self):
return (
self.get_queryset().count()
!= self.request.event.queued_mails.filter(sent__isnull=True).count()
)


class SentMail(
EventPermissionRequired, Sortable, Filterable, PaginationMixin, ListView
Expand Down Expand Up @@ -100,7 +108,7 @@ def show_tracks(self):
return self.request.event.get_feature_flag("use_tracks")


class OutboxSend(EventPermissionRequired, ActionConfirmMixin, TemplateView):
class OutboxSend(ActionConfirmMixin, OutboxList):
permission_required = "orga.send_mails"
action_object_name = ""
action_confirm_label = phrases.base.send
Expand Down Expand Up @@ -145,12 +153,12 @@ def dispatch(self, request, *args, **kwargs):

@cached_property
def queryset(self):
qs = self.request.event.queued_mails.filter(sent__isnull=True)
pks = self.request.GET.get("pks") or ""
if pks:
pks = pks.split(",")
qs = qs.filter(pk__in=pks)
return qs
return self.request.event.queued_mails.filter(sent__isnull=True).filter(
pk__in=pks.split(",")
)
return self.get_queryset()

def post(self, request, *args, **kwargs):
mails = self.queryset
Expand Down Expand Up @@ -228,13 +236,10 @@ def post(self, request, *args, **kwargs):
return redirect(request.event.orga_urls.outbox)


class OutboxPurge(PermissionRequired, ActionConfirmMixin, TemplateView):
class OutboxPurge(ActionConfirmMixin, OutboxList):
permission_required = "orga.purge_mails"
action_object_name = ""

def get_permission_object(self):
return self.request.event

@context
def question(self):
return _("Do you really want to purge {count} mails?").format(
Expand All @@ -250,7 +255,7 @@ def action_back_url(self):

@cached_property
def queryset(self):
return self.request.event.queued_mails.filter(sent__isnull=True)
return self.get_queryset()

def post(self, request, *args, **kwargs):
qs = self.queryset
Expand Down
6 changes: 6 additions & 0 deletions src/pretalx/static/orga/css/_layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,12 @@ footer {
}
}
}
.submit-group form {
.form-group,
button {
margin-bottom: 0;
}
}

.dashboard-history {
max-height: none;
Expand Down

0 comments on commit 05e3773

Please sign in to comment.