forked from CGM_Public/pretix_original
@@ -9,6 +9,7 @@ To use pretix, the most minimal setup consists of:
|
||||
|
||||
* **pretix** and the python packages it depends on
|
||||
* An **WSGI application server** (we recommend gunicorn)
|
||||
* A periodic task runner, e.g. ``cron``
|
||||
|
||||
You get those two bundled in the ``pretix/standalone`` docker image.
|
||||
|
||||
@@ -40,3 +41,11 @@ If you want to use one of the payment providers shipping with pretix, you should
|
||||
|
||||
We will provide a step-by-step tutorial with the first stable release, but all configuration
|
||||
already :ref:`is documented <config>`.
|
||||
|
||||
Set up a cronjob
|
||||
----------------
|
||||
|
||||
You need to set up a cronjob that runs the management command ``runperiodic``. The exact interval is not important
|
||||
but should be something between every minute and every hour. You could for example configure cron like this::
|
||||
|
||||
15,45 * * * * python3 /path/to/pretix/manage.py runperiodic
|
||||
@@ -8,7 +8,7 @@ class PretixBaseConfig(AppConfig):
|
||||
def ready(self):
|
||||
from . import exporter # NOQA
|
||||
from . import payment # NOQA
|
||||
from .services import export, mail, tickets, cart, orders # NOQA
|
||||
from .services import export, mail, tickets, cart, orders, cleanup # NOQA
|
||||
|
||||
try:
|
||||
from .celery import app as celery_app # NOQA
|
||||
|
||||
0
src/pretix/base/management/__init__.py
Normal file
0
src/pretix/base/management/__init__.py
Normal file
0
src/pretix/base/management/commands/__init__.py
Normal file
0
src/pretix/base/management/commands/__init__.py
Normal file
12
src/pretix/base/management/commands/runperiodic.py
Normal file
12
src/pretix/base/management/commands/runperiodic.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from django.core.management import call_command
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from ...signals import periodic_task
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Run periodic tasks"
|
||||
|
||||
def handle(self, *args, **options):
|
||||
periodic_task.send(self)
|
||||
call_command('clearsessions')
|
||||
@@ -299,6 +299,11 @@ class QuestionAnswer(models.Model):
|
||||
else:
|
||||
return self.answer
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if self.orderposition and self.cartposition:
|
||||
raise ValueError('QuestionAnswer cannot be linked to an order and a cart position at the same time.')
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
|
||||
class AbstractPosition(models.Model):
|
||||
"""
|
||||
|
||||
21
src/pretix/base/services/cleanup.py
Normal file
21
src/pretix/base/services/cleanup.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from datetime import timedelta
|
||||
|
||||
from django.dispatch import receiver
|
||||
from django.utils.timezone import now
|
||||
|
||||
from ..models import CachedFile, CartPosition, InvoiceAddress
|
||||
from ..signals import periodic_task
|
||||
|
||||
|
||||
@receiver(signal=periodic_task)
|
||||
def clean_cart_positions(sender, **kwargs):
|
||||
for cp in CartPosition.objects.filter(expires__lt=now() - timedelta(days=14)):
|
||||
cp.delete()
|
||||
for ia in InvoiceAddress.objects.filter(order__isnull=True, last_modified__lt=now() - timedelta(days=14)):
|
||||
ia.delete()
|
||||
|
||||
|
||||
@receiver(signal=periodic_task)
|
||||
def clean_cached_files(sender, **kwargs):
|
||||
for cf in CachedFile.objects.filter(expires__isnull=False, expires__lt=now()):
|
||||
cf.delete()
|
||||
@@ -95,3 +95,13 @@ don't know how to turn it into human-readable text.
|
||||
logentry_display = EventPluginSignal(
|
||||
providing_args=["logentry"]
|
||||
)
|
||||
|
||||
|
||||
"""
|
||||
This is a regular django signal (no pretix event signal) that we send out every
|
||||
time the periodic task cronjob runs. This interval is not sharply defined, it can
|
||||
be everything between a minute and a day. The actions you perform should be
|
||||
idempotent, i.e. it should not make a difference if this is send out more often
|
||||
than expected.
|
||||
"""
|
||||
periodic_task = django.dispatch.Signal()
|
||||
|
||||
Reference in New Issue
Block a user