示例#1
0
def phone_notify_employees(data):

    employee_ids = set([x.employee.id for x in data])

    for person in EmployeeProfile.objects.filter(id__in=employee_ids,
                                           phone_notifications=True).all():

        message = 'You have new shifts posted.\n\n'
        matches = [x for x in data if x.employee.id == person.id]

        for match in matches:
            date = WorkDay.objects.get(id=match.day.id).day_date
            time = match.starting_time
            message += "{} at {}\n".format(
                print_date(date),
                print_time(time)
            )

        num = person.phone_number
        twilio_shift(num, message)
示例#2
0
def email_notify_employees(data):

    employee_ids = set([x.employee.id for x in data])
    from_email = '*****@*****.**'
    subject = 'You have new shifts posted'

    for person in EmployeeProfile.objects.filter(id__in=employee_ids,
                                                 email_notifications=True
                                                 ).all():

        message = ''
        matches = [x for x in data if x.employee.id == person.id]

        for match in matches:
            date = WorkDay.objects.get(id=match.day.id).day_date
            time = match.starting_time
            message += "{} at {}\n".format(
                print_date(date),
                print_time(time)
            )

        send_text_email(from_email, person.email, subject, message)