Skip to content

Commit

Permalink
Sales estimate
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelm committed Feb 6, 2017
1 parent f4f5a68 commit b6dd9a0
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 29 deletions.
82 changes: 53 additions & 29 deletions src/pretix/control/templates/pretixcontrol/waitinglist/index.html
Expand Up @@ -10,6 +10,59 @@ <h1>{% trans "Waiting list" %}</h1>
{% trans "The waiting list is disabled, so if the event is sold out, people cannot add themselves to this list. If you want to enable it, go to the event settings." %}
</div>
{% endif %}
<div class="row">
{% if request.eventperm.can_change_orders %}
<form method="post" class="col-md-6"
action="{% url "control:event.orders.waitinglist.auto" event=request.event.slug organizer=request.organizer.slug %}"
data-asynctask>
<div class="panel panel-default">
<div class="panel-heading">
{% trans "Send vouchers" %}
</div>
<div class="panel-body">
{% csrf_token %}
{% if request.event.settings.waiting_list_auto %}
<p>
{% blocktrans trimmed %}
You have configured that vouchers will automatically be sent to the persons on this list who waited
the longest as soon as capacity becomes available. It might take up to half an hour for the
vouchers to be sent after the capacity is available, so don't worry if entries do not disappear
here immediately. If you want, you can also send them out manually right now.
{% endblocktrans %}
</p>
{% else %}
<p>
{% blocktrans trimmed %}
You have configured that vouchers will <strong>not</strong> be sent automatically.
You can either send them one-by-one in an order of your choice by clicking the
buttons next to a line in this table (if sufficient quota is available) or you can
press the big button below this text to send out as many vouchers as currently
possible to the persons who waitet longest.
{% endblocktrans %}
</p>
{% endif %}
<button class="btn btn-large btn-primary" type="submit">
{% trans "Send as many vouchers as possible" %}
</button>
</div>
</div>
</form>
{% endif %}
<div class="{% if request.eventperm.can_change_orders %}col-md-6{% else %}col-md-12{% endif %}">
<div class="panel panel-default">
<div class="panel-heading">
{% trans "Sales estimate" %}
</div>
<div class="panel-body">
{% blocktrans trimmed with amount=estimate|floatformat:2 currency=request.event.currency %}
If you can make enough room at your event to fit all the persons on the waiting list in, you
could sell tickets worth an additional <strong>{{ amount }} {{ currency }}</strong>.
{% endblocktrans %}
</div>
</div>
</div>
</div>

<p>
<form class="form-inline helper-display-inline" action="" method="get">
<select name="status" class="form-control">
Expand All @@ -32,35 +85,6 @@ <h1>{% trans "Waiting list" %}</h1>
<button class="btn btn-primary" type="submit">{% trans "Filter" %}</button>
</form>
</p>
{% if request.eventperm.can_change_orders %}
<form method="post"
action="{% url "control:event.orders.waitinglist.auto" event=request.event.slug organizer=request.organizer.slug %}"
data-asynctask>
{% csrf_token %}
{% if request.event.settings.waiting_list_auto %}
<p>
{% blocktrans trimmed %}
You have configured that vouchers will automatically be sent to the persons on this list who waited
the longest as soon as capacity becomes available. It might take up to half an hour for the
vouchers to be sent after the capacity is available, so don't worry if entries do not disappear
here immediately. If you want, you can also send them out manually right now.
{% endblocktrans %}
</p>
{% else %}
<p>
{% blocktrans trimmed %}
You have configured that vouchers will <strong>not</strong> be sent automatically. You can
either send them one-by-one in an order of your choice by clicking the buttons next to a line
in this table (if sufficient quota is available) or you can press the big button below this
text to send out as many vouchers as currently possible to the persons who waitet longest.
{% endblocktrans %}
</p>
{% endif %}
<button class="btn btn-large btn-primary" type="submit">
{% trans "Send as many vouchers as possible to the top persons on the list" %}
</button>
</form>
{% endif %}
<form method="post" action="">
{% csrf_token %}
<div class="table-responsive">
Expand Down
13 changes: 13 additions & 0 deletions src/pretix/control/views/waitinglist.py
@@ -1,4 +1,6 @@
from django.contrib import messages
from django.db.models import Sum
from django.db.models.functions import Coalesce
from django.shortcuts import redirect
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
Expand Down Expand Up @@ -111,4 +113,15 @@ def get_context_data(self, **kwargs):
any_avail = True

ctx['any_avail'] = any_avail
ctx['estimate'] = self.get_sales_estimate()
return ctx

def get_sales_estimate(self):
qs = WaitingListEntry.objects.filter(
event=self.request.event
).aggregate(
s=Sum(
Coalesce('variation__default_price', 'item__default_price')
)
)
return qs['s']

0 comments on commit b6dd9a0

Please sign in to comment.