import later, add missing bit of signal, change model reference in signal connection
This commit is contained in:
parent
fe4e47edb0
commit
07b3387831
|
@ -0,0 +1,2 @@
|
||||||
|
default_app_config = 'tickets.apps.TicketsConfig'
|
||||||
|
|
|
@ -10,5 +10,5 @@ class TicketsConfig(AppConfig):
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
# connect the post_save signal, including a dispatch_uid to prevent it being called multiple times in corner cases
|
# connect the post_save signal, including a dispatch_uid to prevent it being called multiple times in corner cases
|
||||||
post_save.connect(ticket_changed, sender='models.ShopTicket', dispatch_uid='shopticket_save_signal')
|
post_save.connect(ticket_changed, sender='tickets.ShopTicket', dispatch_uid='shopticket_save_signal')
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from .models import ShopTicket
|
|
||||||
from ircbot.models import OutgoingIrcMessage
|
|
||||||
|
|
||||||
def ticket_changed(sender, instance, created, **kwargs):
|
def ticket_changed(sender, instance, created, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
@ -15,6 +13,7 @@ def ticket_changed(sender, instance, created, **kwargs):
|
||||||
target = settings.IRCBOT_CHANNELS['orga'] if 'orga' in settings.IRCBOT_CHANNELS else settings.IRCBOT_CHANNELS['default']
|
target = settings.IRCBOT_CHANNELS['orga'] if 'orga' in settings.IRCBOT_CHANNELS else settings.IRCBOT_CHANNELS['default']
|
||||||
|
|
||||||
# get ticket stats
|
# get ticket stats
|
||||||
|
from .models import ShopTicket
|
||||||
ticket_prefix = "BornHack {}".format(datetime.now().year)
|
ticket_prefix = "BornHack {}".format(datetime.now().year)
|
||||||
|
|
||||||
stats = ", ".join(
|
stats = ", ".join(
|
||||||
|
@ -45,6 +44,7 @@ def ticket_changed(sender, instance, created, **kwargs):
|
||||||
).count()
|
).count()
|
||||||
|
|
||||||
# queue the messages
|
# queue the messages
|
||||||
|
from ircbot.models import OutgoingIrcMessage
|
||||||
OutgoingIrcMessage.objects.create(
|
OutgoingIrcMessage.objects.create(
|
||||||
target=target,
|
target=target,
|
||||||
message="%s sold!" % instance.product.name,
|
message="%s sold!" % instance.product.name,
|
||||||
|
@ -54,3 +54,9 @@ def ticket_changed(sender, instance, created, **kwargs):
|
||||||
target=target,
|
target=target,
|
||||||
message="Totals: {}, 1day: {}, 1day child: {}".format(
|
message="Totals: {}, 1day: {}, 1day child: {}".format(
|
||||||
stats,
|
stats,
|
||||||
|
onedaystats,
|
||||||
|
onedaychildstats
|
||||||
|
)[:200],
|
||||||
|
timeout=timezone.now()+timedelta(minutes=10)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue