diff --git a/pretix_advanced_stats/templates/pretix_advanced_stats/advanced_stats.html b/pretix_advanced_stats/templates/pretix_advanced_stats/advanced_stats.html index 25fb881..e617866 100644 --- a/pretix_advanced_stats/templates/pretix_advanced_stats/advanced_stats.html +++ b/pretix_advanced_stats/templates/pretix_advanced_stats/advanced_stats.html @@ -51,35 +51,41 @@

{% trans "Aggregate sellout" %}

-

{{aggregate_previous_event.0.event_name}}

+

{{aggregate_current_event.0.event_name}}

+ {% if aggregate_previous_event.0.event_name %} + + {% endif %} - {% with start_month=aggregate_previous_event.0.month_name|slice:":3" %} - {% for r in aggregate_previous_event|slice:"1:" %} + {% with start_month=aggregate_current_event.0.month_name|slice:":3" %} + {% for r in aggregate_current_event|slice:"1:" %} + {% if aggregate_previous_event.0.event_name %} + + {% endif %} {% endfor %} {% endwith %} -
{% trans "Period" %} {% trans "# tickets" %}Diff with {{aggregate_previous_event.0.event_name}}
{{ start_month }}-{{ r.month_name|slice:":3" }} {{r.cumulative_count}}{{r.diff}}
+ {% if aggregate_previous_event.0.event_name %}
-

{{aggregate_current_event.0.event_name}}

+

{{aggregate_previous_event.0.event_name}}

- {% with start_month=aggregate_current_event.0.month_name|slice:":3" %} - {% for r in aggregate_current_event|slice:"1:" %} + {% with start_month=aggregate_previous_event.0.month_name|slice:":3" %} + {% for r in aggregate_previous_event|slice:"1:" %} @@ -89,11 +95,11 @@

{{aggregate_current_event.0.event_name}}

{% trans "Period" %} {% trans "# tickets" %}
{{ start_month }}-{{ r.month_name|slice:":3" }} {{r.cumulative_count}}
+ {% endif %}
- {%endif%} {% endblock content %} \ No newline at end of file diff --git a/pretix_advanced_stats/views.py b/pretix_advanced_stats/views.py index 75c84e6..8222091 100644 --- a/pretix_advanced_stats/views.py +++ b/pretix_advanced_stats/views.py @@ -130,8 +130,19 @@ def get_context_data(self, **kwargs): if comparison_event else None ) - aggregate_previous_event = self.cumulative_tickets(tickets_previous_event) + aggregate_previous_event = ( + self.cumulative_tickets(tickets_previous_event) + if tickets_previous_event + else [] + ) aggregate_current_event = self.cumulative_tickets(tickets_current_event) + if aggregate_previous_event: + for r_current, r_previous in zip( + aggregate_current_event, aggregate_previous_event + ): + r_current["diff"] = ( + r_current["cumulative_count"] - r_previous["cumulative_count"] + ) ctx.update( { "events": [