Changeset View
Changeset View
Standalone View
Standalone View
wallace/module_invitationpolicy.py
Show All 13 Lines | |||||
# GNU General Public License for more details. | # GNU General Public License for more details. | ||||
# You should have received a copy of the GNU General Public License | # You should have received a copy of the GNU General Public License | ||||
# 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 os | import os | ||||
import signal | |||||
import tempfile | import tempfile | ||||
import time | import time | ||||
from urlparse import urlparse | from urlparse import urlparse | ||||
import urllib | import urllib | ||||
import hashlib | import hashlib | ||||
import traceback | import traceback | ||||
import re | import re | ||||
▲ Show 20 Lines • Show All 1,255 Lines • ▼ Show 20 Lines | def send_update_notification(object, receiving_user, old=None, reply=True, sender=None, comment=None): | ||||
msg = MIMEText(utils.stripped_message(message_text), _charset='utf-8') | msg = MIMEText(utils.stripped_message(message_text), _charset='utf-8') | ||||
msg['To'] = receiving_user['mail'] | msg['To'] = receiving_user['mail'] | ||||
msg['Date'] = formatdate(localtime=True) | msg['Date'] = formatdate(localtime=True) | ||||
msg['Subject'] = utils.str2unicode(_('"%s" has been updated') % (object.get_summary())) | msg['Subject'] = utils.str2unicode(_('"%s" has been updated') % (object.get_summary())) | ||||
msg['From'] = Header(utils.str2unicode('%s' % orgname) if orgname else '') | msg['From'] = Header(utils.str2unicode('%s' % orgname) if orgname else '') | ||||
msg['From'].append("<%s>" % orgemail) | msg['From'].append("<%s>" % orgemail) | ||||
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(orgemail, receiving_user['mail'], msg.as_string()) | result = modules._sendmail(orgemail, receiving_user['mail'], msg.as_string()) | ||||
log.debug(_("Sent update notification to %r: %r") % (receiving_user['mail'], result), level=8) | log.debug(_("Sent update notification to %r: %r") % (receiving_user['mail'], result), level=8) | ||||
signal.alarm(0) | |||||
def send_cancel_notification(object, receiving_user, deleted=False, sender=None, comment=None): | def send_cancel_notification(object, receiving_user, deleted=False, sender=None, comment=None): | ||||
""" | """ | ||||
Send a notification about event/task cancellation | Send a notification about event/task cancellation | ||||
""" | """ | ||||
from email.MIMEText import MIMEText | from email.MIMEText import MIMEText | ||||
from email.Utils import formatdate | from email.Utils import formatdate | ||||
from email.header import Header | from email.header import Header | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | def send_cancel_notification(object, receiving_user, deleted=False, sender=None, comment=None): | ||||
msg = MIMEText(utils.stripped_message(message_text), _charset='utf-8') | msg = MIMEText(utils.stripped_message(message_text), _charset='utf-8') | ||||
msg['To'] = receiving_user['mail'] | msg['To'] = receiving_user['mail'] | ||||
msg['Date'] = formatdate(localtime=True) | msg['Date'] = formatdate(localtime=True) | ||||
msg['Subject'] = utils.str2unicode(_('"%s" has been cancelled') % (object.get_summary())) | msg['Subject'] = utils.str2unicode(_('"%s" has been cancelled') % (object.get_summary())) | ||||
msg['From'] = Header(utils.str2unicode('%s' % orgname) if orgname else '') | msg['From'] = Header(utils.str2unicode('%s' % orgname) if orgname else '') | ||||
msg['From'].append("<%s>" % orgemail) | msg['From'].append("<%s>" % orgemail) | ||||
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(orgemail, receiving_user['mail'], msg.as_string()) | result = modules._sendmail(orgemail, receiving_user['mail'], msg.as_string()) | ||||
log.debug(_("Sent cancel notification to %r: %r") % (receiving_user['mail'], result), level=8) | log.debug(_("Sent cancel notification to %r: %r") % (receiving_user['mail'], result), level=8) | ||||
signal.alarm(0) | |||||
def is_auto_reply(user, sender_email, type): | def is_auto_reply(user, sender_email, type): | ||||
accept_available = False | accept_available = False | ||||
accept_conflicts = False | accept_conflicts = False | ||||
for policy in get_matching_invitation_policies(user, sender_email, object_type_conditons.get(type, COND_TYPE_EVENT)): | for policy in get_matching_invitation_policies(user, sender_email, object_type_conditons.get(type, COND_TYPE_EVENT)): | ||||
if policy & (ACT_ACCEPT | ACT_REJECT | ACT_DELEGATE): | if policy & (ACT_ACCEPT | ACT_REJECT | ACT_DELEGATE): | ||||
if check_policy_condition(policy, True): | if check_policy_condition(policy, True): | ||||
accept_available = True | accept_available = True | ||||
▲ Show 20 Lines • Show All 93 Lines • Show Last 20 Lines |