示例#1
0
def sendStartNotifications(logger):
    if getRoomBookingOption('notificationHour') != datetime.now().hour:
        if DEBUG:
            print 'Outside notification hour. Continuing anyway due to debug mode.'
        else:
            return
    days = _getRoomSpecificNotificationBeforeDays()
    days.add(getRoomBookingOption('notificationBefore'))
    dates = [date.today() + timedelta(days=day) for day in days]
    if DEBUG:
        print 'Dates to check: %r' % map(str, dates)
    for resv in ReservationBase.getReservations(days=dates): # for testing, remove location later
        se = resv.getStartEndNotification()
        se.sendStartNotification(logger)
示例#2
0
def sendStartNotifications(logger):
    if getRoomBookingOption('notificationHour') != datetime.now().hour:
        if DEBUG:
            print 'Outside notification hour. Continuing anyway due to debug mode.'
        else:
            return
    days = _getRoomSpecificNotificationBeforeDays()
    days.add(getRoomBookingOption('notificationBefore'))
    dates = [date.today() + timedelta(days=day) for day in days]
    if DEBUG:
        print 'Dates to check: %r' % map(str, dates)
    for resv in ReservationBase.getReservations(
            days=dates):  # for testing, remove location later
        se = resv.getStartEndNotification()
        se.sendStartNotification(logger)
示例#3
0
def sendReservationStartStopNotification(resv, which, occurrence):
    if which == 'start' and resv.room.resvStartNotification:
        msg = getRoomBookingOption('startNotificationEmail')
        subject = getRoomBookingOption('startNotificationEmailSubject')
    elif which == 'end' and resv.room.resvEndNotification:
        msg = getRoomBookingOption('endNotificationEmail')
        subject = getRoomBookingOption('endNotificationEmailSubject')
    else:
        return

    av = resv.bookedForUser
    if av:
        bookedForDetails = '%s %s\n%s' % (av.getFullName(), av.getPersonId()
                                          or '', av.getEmail())
    else:
        bookedForDetails = '%s\n%s' % (resv.bookedForName, resv.contactEmail)

    msgArgs = {
        'bookedForUser': bookedForDetails,
        'roomName': resv.room.getFullName(),
        'roomAtts': resv.room.customAtts,
        'bookingStart': formatDateTime(resv.startDT),
        'bookingEnd': formatDateTime(resv.endDT),
        'occStart': formatDateTime(occurrence.startDT),
        'occEnd': formatDateTime(occurrence.endDT),
        'detailsLink': urlHandlers.UHRoomBookingBookingDetails.getURL(resv)
    }

    recipients = set()
    recipients.update(getRoomBookingOption('notificationEmails'))
    if getRoomBookingOption('notificationEmailsToBookedFor'):
        recipients.update(getEmailList(resv.contactEmail))
    if resv.room.resvNotificationToResponsible:
        recipients.add(resv.room.getResponsible().getEmail())
    maildata = {
        'fromAddr': Config.getInstance().getNoReplyEmail(),
        'toList': list(recipients),
        'subject': subject.format(**msgArgs),
        'body': msg.format(**msgArgs)
    }
    GenericMailer.send(GenericNotification(maildata))
示例#4
0
def sendReservationStartStopNotification(resv, which, occurrence):
    if which == 'start' and resv.room.resvStartNotification:
        msg = getRoomBookingOption('startNotificationEmail')
        subject = getRoomBookingOption('startNotificationEmailSubject')
    elif which == 'end' and resv.room.resvEndNotification:
        msg = getRoomBookingOption('endNotificationEmail')
        subject = getRoomBookingOption('endNotificationEmailSubject')
    else:
        return

    av = resv.bookedForUser
    if av:
        bookedForDetails = '%s %s\n%s' % (av.getFullName(), av.getPersonId() or '', av.getEmail())
    else:
        bookedForDetails = '%s\n%s' % (resv.bookedForName, resv.contactEmail)

    msgArgs = {
        'bookedForUser': bookedForDetails,
        'roomName': resv.room.getFullName(),
        'roomAtts': resv.room.customAtts,
        'bookingStart': formatDateTime(resv.startDT),
        'bookingEnd': formatDateTime(resv.endDT),
        'occStart': formatDateTime(occurrence.startDT),
        'occEnd': formatDateTime(occurrence.endDT),
        'detailsLink': urlHandlers.UHRoomBookingBookingDetails.getURL(resv)
    }

    recipients = set()
    recipients.update(getRoomBookingOption('notificationEmails'))
    if getRoomBookingOption('notificationEmailsToBookedFor'):
        recipients.update(getEmailList(resv.contactEmail))
    if resv.room.resvNotificationToResponsible:
        recipients.add(resv.room.getResponsible().getEmail())
    maildata = {
        'fromAddr': Config.getInstance().getNoReplyEmail(),
        'toList': list(recipients),
        'subject': subject.format(**msgArgs),
        'body': msg.format(**msgArgs)
    }
    GenericMailer.send(GenericNotification(maildata))
示例#5
0
 def _daysBefore(self):
     roomSpecificDays = self._resv.room.resvStartNotificationBefore
     if roomSpecificDays is not None:
         return timedelta(days=roomSpecificDays)
     return timedelta(days=getRoomBookingOption('notificationBefore'))
示例#6
0
 def _daysBefore(self):
     roomSpecificDays = self._resv.room.resvStartNotificationBefore
     if roomSpecificDays is not None:
         return timedelta(days=roomSpecificDays)
     return timedelta(days=getRoomBookingOption('notificationBefore'))