Esempio n. 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)
Esempio n. 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)
Esempio n. 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))
Esempio n. 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))
Esempio n. 5
0
 def _daysBefore(self):
     roomSpecificDays = self._resv.room.resvStartNotificationBefore
     if roomSpecificDays is not None:
         return timedelta(days=roomSpecificDays)
     return timedelta(days=getRoomBookingOption('notificationBefore'))
Esempio n. 6
0
 def _daysBefore(self):
     roomSpecificDays = self._resv.room.resvStartNotificationBefore
     if roomSpecificDays is not None:
         return timedelta(days=roomSpecificDays)
     return timedelta(days=getRoomBookingOption('notificationBefore'))