Example #1
0
def task_immediate_reminder():
    """
    tries to send a reminder for appointments happening in the next 45 minutes
    that have NOT been notified probably these were created very soon before
    the appointment start and thus were not caught by any other task

    The idea is to catch any appointments happening very soon that have NOT
    been notified
    """
    t = timezone.localtime(timezone.now())
    fro = t
    to = t + timedelta(minutes=45)

    period = Period(
        Event.objects.exclude(appointment=None).exclude(
            appointment__client=None).exclude(
                appointment__status=Appointment.NOTIFIED).exclude(
                    appointment__status=Appointment.CANCELED), fro, to)
    event_objects = period.get_occurrences()
    event_ids = list(set([x.event.id for x in event_objects]))

    send_period_reminders(event_ids,
                          sendsms=True,
                          turn_off_reminders=True,
                          mailgun_campaign_id="fi0cz")
Example #2
0
def task_hour_to_reminder():
    """
    tries to send a reminder approximately one hour before an appointment
    given a time, say 7AM
    we look for appointments that are happening
    between 46 minutes and 1 hour from the given time
    in our case 7:46AM and 8AM
    if time now i6 7:45 we get fro=8:31 and to = 8:45
    we use 46 minutes to avoid cases where events happening at
    exactly *:15, *:30, *:45, or *:00 dont get multiple reminders

    The idea is to catch any appointments happening soon that have NOT been notified
    """
    t = timezone.localtime(timezone.now())
    fro = t + timedelta(minutes=46)
    to = t + timedelta(hours=1)

    period = Period(
        Event.objects.exclude(appointment=None).exclude(
            appointment__client=None).exclude(
                appointment__status=Appointment.NOTIFIED).exclude(
                    appointment__status=Appointment.CANCELED).exclude(
                        appointment__status=Appointment.CONFIRMED), fro, to)
    event_objects = period.get_occurrences()
    event_ids = list(set([x.event.id for x in event_objects]))

    send_period_reminders(event_ids,
                          sendsms=True,
                          turn_off_reminders=True,
                          mailgun_campaign_id="fi0bd")
Example #3
0
def task_hour_to_reminder():
    """
    tries to send a reminder approximately one hour before an appointment
    given a time, say 7AM
    we look for appointments that are happening
    between 46 minutes and 1 hour from the given time
    in our case 7:46AM and 8AM
    if time now i6 7:45 we get fro=8:31 and to = 8:45
    we use 46 minutes to avoid cases where events happening at
    exactly *:15, *:30, *:45, or *:00 dont get multiple reminders

    The idea is to catch any appointments happening soon that have NOT been notified
    """
    t = timezone.localtime(timezone.now())
    fro = t + timedelta(minutes=46)
    to = t + timedelta(hours=1)

    period = Period(Event.objects.exclude(appointment=None).exclude(
        appointment__client=None).exclude(
        appointment__status=Appointment.NOTIFIED).exclude(
        appointment__status=Appointment.CANCELED).exclude(
        appointment__status=Appointment.CONFIRMED), fro, to)
    event_objects = period.get_occurrences()
    event_ids = list(set([x.event.id for x in event_objects]))

    send_period_reminders(event_ids, sendsms=True, turn_off_reminders=True, mailgun_campaign_id="fi0bd")
Example #4
0
def task_morning_reminders():
    """
    Sends a reminder to all the appointments happening today
    currently sends at 7am
    """
    t = timezone.now().date()
    fro = datetime(year=t.year, month=t.month, day=t.day, hour=7,
                   tzinfo=timezone.get_current_timezone())
    to = fro + timedelta(1)
    period = Period(Event.objects.exclude(appointment=None).exclude(
        appointment__client=None).exclude(
        appointment__status=Appointment.CANCELED).exclude(
        appointment__status=Appointment.CONFIRMED), fro, to)
    event_objects = period.get_occurrences()
    event_ids = list(set([x.event.id for x in event_objects]))

    send_period_reminders(event_ids, sendsms=True, mailgun_campaign_id="ffz23")
Example #5
0
def task_immediate_reminder():
    """
    tries to send a reminder for appointments happening in the next 45 minutes that have NOT been notified
    probably these were created very soon before the appointment start and thus were not caught by any other task
    The idea is to catch any appointments happening very soon that have NOT been notified
    """
    t = timezone.localtime(timezone.now())
    fro = t
    to = t + timedelta(minutes=45)

    period = Period(Event.objects.exclude(appointment=None).exclude(
        appointment__client=None).exclude(
        appointment__status=Appointment.NOTIFIED).exclude(
        appointment__status=Appointment.CANCELED).exclude(
        appointment__status=Appointment.CONFIRMED), fro, to)
    event_objects = period.get_occurrences()
    event_ids = list(set([x.event.id for x in event_objects]))

    send_period_reminders(event_ids, sendsms=True, turn_off_reminders=True, mailgun_campaign_id="fi0cz")
Example #6
0
def task_morning_reminders():
    """
    Sends a reminder to all the appointments happening today
    currently sends at 7am
    """
    t = timezone.now().date()
    fro = datetime(year=t.year,
                   month=t.month,
                   day=t.day,
                   hour=7,
                   tzinfo=timezone.get_current_timezone())
    to = fro + timedelta(1)
    period = Period(
        Event.objects.exclude(appointment=None).exclude(
            appointment__client=None).exclude(
                appointment__status=Appointment.CANCELED), fro, to)
    event_objects = period.get_occurrences()
    event_ids = list(set([x.event.id for x in event_objects]))

    send_period_reminders(event_ids, sendsms=True, mailgun_campaign_id="ffz23")
Example #7
0
def task_48hrbefore_reminders():
    """
    Sends a reminder to all the UN-NOTIFIED appointments
    happening in the next 48hrs
    currently sends at 6pm
    """
    t = timezone.now().date()
    fro = datetime(year=t.year,
                   month=t.month,
                   day=t.day,
                   hour=0,
                   tzinfo=timezone.get_current_timezone())
    fro = fro + timedelta(2)
    to = fro + timedelta(1)
    period = Period(
        Event.objects.exclude(appointment=None).exclude(
            appointment__client=None).exclude(
                appointment__status=Appointment.NOTIFIED).exclude(
                    appointment__status=Appointment.CANCELED), fro, to)
    event_objects = period.get_occurrences()
    event_ids = list(set([x.event.id for x in event_objects]))

    send_period_reminders(event_ids, sendsms=True, mailgun_campaign_id="fi0bc")