Changeset View
Changeset View
Standalone View
Standalone View
wallace/module_resources.py
Show All 16 Lines | |||||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
# | # | ||||
import datetime | import datetime | ||||
import icalendar | import icalendar | ||||
import os | import os | ||||
import pytz | import pytz | ||||
import random | import random | ||||
import signal | |||||
import tempfile | import tempfile | ||||
import time | import time | ||||
from urlparse import urlparse | from urlparse import urlparse | ||||
from dateutil.tz import tzlocal | from dateutil.tz import tzlocal | ||||
import base64 | import base64 | ||||
import uuid | import uuid | ||||
import re | import re | ||||
▲ Show 20 Lines • Show All 1,317 Lines • ▼ Show 20 Lines | if notify or not success: | ||||
msg['To'] = owner['mail'] | msg['To'] = owner['mail'] | ||||
msg['From'] = resource['mail'] | msg['From'] = resource['mail'] | ||||
msg['Date'] = formatdate(localtime=True) | msg['Date'] = formatdate(localtime=True) | ||||
msg['Subject'] = utils.str2unicode(_('Booking for %s has been %s') % ( | msg['Subject'] = utils.str2unicode(_('Booking for %s has been %s') % ( | ||||
resource['cn'], participant_status_label(status) if success else _('failed') | resource['cn'], participant_status_label(status) if success else _('failed') | ||||
)) | )) | ||||
seed = random.randint(0, 6) | |||||
alarm_after = (seed * 10) + 60 | |||||
log.debug(_("Set alarm to %s seconds") % (alarm_after), level=8) | |||||
signal.alarm(alarm_after) | |||||
result = modules._sendmail(resource['mail'], owner['mail'], msg.as_string()) | result = modules._sendmail(resource['mail'], owner['mail'], msg.as_string()) | ||||
log.debug(_("Owner notification was sent successfully: %r") % result, level=8) | log.debug(_("Owner notification was sent successfully: %r") % result, level=8) | ||||
signal.alarm(0) | |||||
def owner_notification_text(resource, owner, event, success): | def owner_notification_text(resource, owner, event, success): | ||||
organizer = event.get_organizer() | organizer = event.get_organizer() | ||||
status = event.get_attendee_by_email(resource['mail']).get_participant_status(True) | status = event.get_attendee_by_email(resource['mail']).get_participant_status(True) | ||||
if success: | if success: | ||||
message_text = _(""" | message_text = _(""" | ||||
The resource booking for %(resource)s by %(orgname)s <%(orgemail)s> has been %(status)s for %(date)s. | The resource booking for %(resource)s by %(orgname)s <%(orgemail)s> has been %(status)s for %(date)s. | ||||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |