blob: 281db9230c6ea6de16647bb614b42f251bf52ce9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
##############################################################################
# Copyright (c) 2016 Max Breitenfeldt and others.
# Copyright (c) 2018 Parker Berberian, Sawyer Bergeron, and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
from booking.models import Booking
from celery import shared_task
from django.utils import timezone
from api.views import liblaas_end_booking
# todo - make a task to check for expired bookings
@shared_task
def end_expired_bookings():
cleanup_set = Booking.objects.filter(end__lte=timezone.now(), ).filter(complete=False)
for booking in cleanup_set:
booking.complete = True
if (booking.aggregateId):
print("ending booking " + str(booking.id) + " with agg id: ", booking.aggregateId)
liblaas_end_booking(booking.aggregateId)
else:
print("booking " + str(booking.id) + " has no agg id")
booking.save()
|