mirror of
https://github.com/pretix/pretix.git
synced 2026-05-04 15:04:03 +00:00
Show paid tickets instead of available quota in event list
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.5 on 2017-10-18 09:06
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
def clear_quota_caches(app, schema_editor):
|
||||
Quota = app.get_model('pretixbase', 'Quota')
|
||||
Quota.objects.all().update(cached_availability_time=None)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pretixbase', '0080_auto_20171016_1553'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='quota',
|
||||
name='cached_availability_paid_orders',
|
||||
field=models.PositiveIntegerField(blank=True, null=True),
|
||||
),
|
||||
migrations.RunPython(
|
||||
clear_quota_caches, migrations.RunPython.noop
|
||||
)
|
||||
]
|
||||
@@ -727,6 +727,7 @@ class Quota(LoggedModel):
|
||||
)
|
||||
cached_availability_state = models.PositiveIntegerField(null=True, blank=True)
|
||||
cached_availability_number = models.PositiveIntegerField(null=True, blank=True)
|
||||
cached_availability_paid_orders = models.PositiveIntegerField(null=True, blank=True)
|
||||
cached_availability_time = models.DateTimeField(null=True, blank=True)
|
||||
|
||||
class Meta:
|
||||
@@ -783,8 +784,13 @@ class Quota(LoggedModel):
|
||||
self.cached_availability_state = res[0]
|
||||
self.cached_availability_number = res[1]
|
||||
self.cached_availability_time = now_dt
|
||||
if self.size is None:
|
||||
self.cached_availability_paid_orders = self.count_pending_orders()
|
||||
self.save(
|
||||
update_fields=['cached_availability_state', 'cached_availability_number', 'cached_availability_time'],
|
||||
update_fields=[
|
||||
'cached_availability_state', 'cached_availability_number', 'cached_availability_time',
|
||||
'cached_availability_paid_orders'
|
||||
],
|
||||
clear_cache=False
|
||||
)
|
||||
|
||||
@@ -799,8 +805,9 @@ class Quota(LoggedModel):
|
||||
if size_left is None:
|
||||
return Quota.AVAILABILITY_OK, None
|
||||
|
||||
# TODO: Test for interference with old versions of Item-Quota-relations, etc.
|
||||
size_left -= self.count_paid_orders()
|
||||
paid_orders = self.count_paid_orders()
|
||||
self.cached_availability_paid_orders = paid_orders
|
||||
size_left -= paid_orders
|
||||
if size_left <= 0:
|
||||
return Quota.AVAILABILITY_GONE, 0
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@ from ..signals import periodic_task
|
||||
|
||||
@receiver(signal=periodic_task)
|
||||
def build_all_quota_caches(sender, **kwargs):
|
||||
refresh_quota_cashes.apply_async()
|
||||
refresh_quota_caches.apply_async()
|
||||
|
||||
|
||||
@app.task
|
||||
def refresh_quota_cashes():
|
||||
def refresh_quota_caches():
|
||||
last_activity = LogEntry.objects.filter(
|
||||
event=OuterRef('event_id'),
|
||||
).order_by().values('event').annotate(
|
||||
|
||||
Reference in New Issue
Block a user