def notify_payment_confirmation(registrant, amount): event = registrant.getConference() reg_form = registrant.getRegistrationForm() from_address = reg_form.getNotificationSender() currency = payment_event_settings.get(event, 'currency') # Send email to organizers notification = reg_form.getNotification() to_list = notification.getToList() cc_list = notification.getCCList() if to_list or cc_list: reg_page = url_for('event_mgmt.confModifRegistrants-modification', registrant, _external=True, _secure=True) tpl = get_template_module('payment/emails/payment_confirmation_organizers.txt', event=event, registrant=registrant, amount=amount, currency=currency, reg_page=reg_page) yield make_email(to_list, cc_list, from_address=from_address, subject=tpl.get_subject(), body=tpl.get_body()) # Send email to the registrant if reg_form.isSendPaidEmail(): success_email_msg = payment_event_settings.get(event, 'success_email') params = {} if not registrant.getAvatar(): params = {'registrantId': registrant.getId(), 'authkey': registrant.getRandomId()} reg_page = url_for('event.confRegistrationFormDisplay', event, _external=True, _secure=True, **params) tpl = get_template_module('payment/emails/payment_confirmation_registrant.txt', event=event, registrant=registrant, amount=amount, currency=currency, success_email_msg=success_email_msg, reg_page=reg_page) yield make_email(registrant.getEmail(), from_address=from_address, subject=tpl.get_subject(), body=tpl.get_body())
def notify_registration_modification(event, registrant): reg_form = registrant.getRegistrationForm() from_address = reg_form.getNotificationSender() reg_details = _get_reg_details(reg_form, registrant) # Send email to organizers notification = reg_form.getNotification() to_list = notification.getToList() cc_list = notification.getCCList() if to_list or cc_list: reg_page = url_for('event_mgmt.confModifRegistrants-modification', registrant, _external=True, _secure=True) tpl = get_template_module('events/registration/emails/registration_modification_organizers.html', event=event, registrant=registrant, reg_page=reg_page, reg_details=reg_details) yield make_email(to_list, cc_list, from_address=from_address, subject=tpl.get_subject(), body=tpl.get_body(), html=True) # Send email to the registrant if reg_form.isSendRegEmail(): needs_to_pay = registrant.doPay() and payment_event_settings.get(event, 'enabled') params = {} if not registrant.getAvatar(): params = {'registrantId': registrant.getId(), 'authkey': registrant.getRandomId()} reg_page = url_for('event.confRegistrationFormDisplay', event, _external=True, _secure=True, **params) tpl = get_template_module('events/registration/emails/registration_modification_registrant.html', event=event, registrant=registrant, payment_enabled=payment_event_settings.get(event, 'enabled'), reg_page=reg_page, needs_to_pay=needs_to_pay, reg_details=reg_details) yield make_email(registrant.getEmail(), from_address=from_address, subject=tpl.get_subject(), body=tpl.get_body(), html=True)
def notify_amount_inconsistency(registrant, amount): event = registrant.getConference() currency = payment_event_settings.get(event, 'currency') to = event.getCreator().getEmail() body = render_template('payment/emails/payment_inconsistency_email_to_manager.txt', event=event, registrant=registrant, amount=amount, currency=currency) return make_email(to, subject='Payment inconsistency', body=body)
def send_submission_notification(self, submission): if not self.notifications_enabled: return template_module = get_template_module('events/surveys/emails/new_submission_email.txt', submission=submission) email = make_email(bcc_list=self.new_submission_emails, template=template_module) send_email(email, event=self.event_new, module='Surveys') logger.info('Sending submission notification for survey %s', self)
def notify_amount_inconsistency(registration, amount): event = registration.registration_form.event currency = payment_event_settings.get(event, 'currency') to = event.as_event.creator.email body = render_template('payment/emails/payment_inconsistency_email_to_manager.txt', event=event, registration=registration, amount=amount, currency=currency) return make_email(to, subject='Payment inconsistency', body=body)
def _registered(user, identity, from_moderation, **kwargs): from indico.modules.users.util import get_admin_emails if (from_moderation or identity is None or identity.provider != 'indico' or not user_management_settings.get('notify_account_creation')): return tpl = get_template_module('users/emails/profile_registered_admins.txt', user=user) send_email(make_email(get_admin_emails(), template=tpl))
def notify_event_creation(event, occurrences=None): """Send email notifications when a new Event is created :param event: The `Event` that has been created. :param occurrences: A list of event occurrences in case of a series of events. If specified, the links and dates/times are only taken from the events in this list. """ emails = set() query = (event.category.chain_query. filter(Category.notify_managers | (Category.event_creation_notification_emails != [])) .options(joinedload('acl_entries'))) for cat in query: emails.update(cat.event_creation_notification_emails) if cat.notify_managers: for manager in cat.get_manager_list(): if manager.is_single_person: emails.add(manager.email) elif manager.is_group: emails.update(x.email for x in manager.get_members()) if emails: template = get_template_module('events/emails/event_creation.txt', event=event, occurrences=occurrences) send_email(make_email(bcc_list=emails, template=template))
def _sendReport(self): cfg = Config.getInstance() data = json.loads(self._msg) template = get_template_module('emails/error_report.txt', comment=self._comments, traceback=data['traceback'], request_info=pformat(data['request_info']), server_name=url_parse(cfg.getBaseURL()).netloc) send_email(make_email(cfg.getSupportEmail(), reply_address=self._userMail, template=template), skip_queue=True)
def notify_comment(person, paper, comment, submitter): event = paper.event receiver_name = person.first_name or 'user' template = get_template_module('events/papers/emails/comment.html', event=event, receiver=receiver_name, contribution=paper.contribution, comment=comment, submitter=submitter) email = make_email(to_list=person.email, template=template, html=True) send_email(email, event=event, module='Papers', user=session.user)
def notify_reservation_digest(reservation, occurrences): if not occurrences: return if reservation.end_dt.date() < date.today(): raise ValueError("This reservation has already ended") if reservation.repeat_frequency != RepeatFrequency.WEEK: raise ValueError("This reservation is not weekly") if any(occ.reservation != reservation for occ in occurrences): raise ValueError("Some occurrences don't belong to the reservation") if any(occurrences[0].start_dt.month != occ.start_dt.month for occ in occurrences): raise ValueError("Occurrences happening in different months") to_list = [] reservation_user = reservation.booked_for_user if reservation_user is not None: to_list.append(reservation_user.email) cc_list = [] room = reservation.room if room.notification_for_responsible: cc_list.append(room.owner.email) if not to_list and not cc_list: return subject = 'Reservation reminder digest' text = render_template('rb/emails/reservations/reminders/reservation_digest.txt', reservation=reservation, occurrences=occurrences, owner=reservation_user) return make_email(to_list=to_list, cc_list=cc_list, subject=subject, body=text)
def _send(action, user, plugin, event, room, template_module): to_list = {user.email} cc_list = plugin.get_notification_cc_list(action, room, event) - to_list bcc_list = plugin.get_notification_bcc_list(action, room, event) - cc_list - to_list email = make_email(to_list, cc_list, bcc_list, template=template_module, html=True) send_email(email, event, plugin.friendly_name)
def notify_invitation(invitation, email_subject, email_body, from_address): """Send a notification about a new registration invitation.""" email_body = replace_placeholders('registration-invitation-email', email_body, invitation=invitation) email_subject = replace_placeholders('registration-invitation-email', email_subject, invitation=invitation) template = get_template_module('emails/custom.html', subject=email_subject, body=email_body) email = make_email(invitation.email, from_address=from_address, template=template, html=True) send_email(email, invitation.registration_form.event, 'Registration', session.user)
def send_abstract_notifications(abstract): """Send abstract notification e-mails. :param abstract: the abstract that is going to be checked against the event's notification rules """ for email_tpl in abstract.event_new.abstract_email_templates: matched = False for rule in email_tpl.rules: if check_rule('abstract-notifications', rule, abstract=abstract, event=abstract.event_new): matched = True to_recipients = [] if email_tpl.include_submitter: to_recipients.append(abstract.submitter.email) if email_tpl.include_authors: to_recipients += [author.email for author in abstract.primary_authors] cc_recipients = list(email_tpl.extra_cc_emails) if email_tpl.include_coauthors: cc_recipients += [author.email for author in abstract.secondary_authors] tpl = get_abstract_notification_tpl_module(email_tpl, abstract) email = make_email(to_list=to_recipients, cc_list=cc_recipients, reply_address=email_tpl.reply_to_address, template=tpl) send_email(email, event=abstract.event_new, user=session.user) abstract.email_logs.append(AbstractEmailLogEntry.create_from_email(email, email_tpl=email_tpl, user=session.user)) if email_tpl.stop_on_match and matched: break
def _send_confirmation(self, email): token_storage = GenericCache('confirm-email') data = {'email': email, 'user_id': self.user.id} token = make_unique_token(lambda t: not token_storage.get(t)) token_storage.set(token, data, 24 * 3600) send_email(make_email(email, template=get_template_module('users/emails/verify_email.txt', user=self.user, email=email, token=token)))
def send_submission_notification(self, submission): if not self.notifications_enabled: return template_module = get_template_module("events/surveys/emails/new_submission_email.txt", submission=submission) email = make_email(bcc_list=self.new_submission_emails, template=template_module) send_email(email, event=self.event, module="Surveys") logger.info("Sending submission notification for survey {}".format(self))
def _process(self): user, identity = register_user(self.request.email, self.request.extra_emails, self.request.user_data, self.request.identity_data, self.request.settings) tpl = get_template_module('users/emails/registration_request_accepted.txt', user=user) send_email(make_email(self.request.email, template=tpl)) flash(_('The request has been approved.'), 'success') return jsonify_data()
def send_start_notification(self): if not self.notifications_enabled or self.start_notification_sent or not self.event_new.has_feature('surveys'): return template_module = get_template_module('events/surveys/emails/start_notification_email.txt', survey=self) email = make_email(bcc_list=self.start_notification_recipients, template=template_module) send_email(email, event=self.event_new, module='Surveys') logger.info('Sending start notification for survey %s', self) self.start_notification_sent = True
def compose_email_to_user(self, **mail_params): creator = self.reservation.created_by_user to_list = {creator.email} if self.reservation.contact_email: to_list.add(self.reservation.contact_email) subject = self._get_email_subject(**mail_params) body = self._make_body(mail_params, reservation=self.reservation) return make_email(to_list=to_list, subject=subject, body=body)
def send_start_notification(self): if not self.notifications_enabled or self.start_notification_sent or not self.event.has_feature("surveys"): return template_module = get_template_module("events/surveys/emails/start_notification_email.txt", survey=self) email = make_email(bcc_list=self.start_notification_recipients, template=template_module) send_email(email, event=self.event, module="Surveys") logger.info("Sending start notification for survey {}".format(self)) self.start_notification_sent = True
def _send(event, template_module): from indico_chat.plugin import ChatPlugin to_list = set(ChatPlugin.settings.get('notify_emails')) if not to_list: return send_email(make_email(to_list, template=template_module), event, 'Chat')
def notify_paper_review_submission(review): event = review.revision.paper.event if not paper_reviewing_settings.get(event, 'notify_judge_on_review'): return for judge in review.revision.paper.contribution.paper_judges: template = get_template_module('events/papers/emails/review_submission_to_judge.html', event=event, review=review, contribution=review.revision.paper.contribution, receiver=judge) email = make_email(to_list=judge.email, template=template, html=True) send_email(email, event=event, module='Papers', user=session.user)
def notify_request(owner, blocking, blocked_rooms): """ Notifies room owner about blockings he has to approve. Expects only blockings for rooms owned by the specified owner """ subject = 'Confirm room blockings' body = render_template('rb/emails/blockings/awaiting_confirmation_email_to_manager.txt', owner=owner, blocking=blocking, blocked_rooms=blocked_rooms) return make_email(owner.email, subject=subject, body=body)
def _send_emails(self, form): for registration in self.registrations: email_body = replace_placeholders('registration-email', form.body.data, regform=self.regform, registration=registration) template = get_template_module('events/registration/emails/custom_email.html', email_subject=form.subject.data, email_body=email_body) email = make_email(to_list=registration.email, cc_list=form.cc_addresses.data, from_address=form.from_address.data, template=template, html=True) send_email(email, self.event, 'Registration')
def compose_email_to_vc_support(self, **mail_params): from indico.modules.rb import settings as rb_settings if self.reservation.is_accepted and self.reservation.uses_vc: to_list = rb_settings.get('vc_support_emails') if to_list: subject = self._get_email_subject(**mail_params) body = self._make_body(mail_params, reservation=self.reservation) return make_email(to_list=to_list, subject=subject, body=body)
def _send_confirmation(email, salt, endpoint, template, template_args=None, url_args=None, data=None): template_args = template_args or {} url_args = url_args or {} token = secure_serializer.dumps(data or email, salt=salt) url = url_for(endpoint, token=token, _external=True, **url_args) template_module = get_template_module(template, email=email, url=url, **template_args) send_email(make_email(email, template=template_module)) flash(_('We have sent you a verification email. Please check your mailbox within the next hour and open ' 'the link in that email.')) return redirect(url_for(endpoint, **url_args))
def _send_email(self, email, comment): # using reply-to for the user email would be nicer, but email clients # usually only show the from address and it's nice to immediately see # whether an error report has an email address associated and if # multiple reports came from the same person template = get_template_module('core/emails/error_report.txt', comment=comment, error_data=self.error_data, server_name=url_parse(config.BASE_URL).netloc) send_email(make_email(config.SUPPORT_EMAIL, from_address=(email or config.NO_REPLY_EMAIL), template=template))
def send_submission_notification(self, submission): if not self.notifications_enabled: return template_module = get_template_module( 'events/surveys/emails/new_submission_email.txt', submission=submission) email = make_email(bcc_list=self.new_submission_emails, template=template_module) send_email(email, event=self.event_new, module='Surveys') logger.info('Sending submission notification for survey %s', self)
def notify_paper_assignment(user, role, contributions, event, assign): template = get_template_module( 'events/papers/emails/paper_assignment.html', event=event, contribs=contributions, receiver=user, assign=assign, role=role) email = make_email(to_list=user.email, template=template, html=True) send_email(email, event=event, module='Papers', user=session.user)
def notify_paper_revision_submission(revision): event = revision.paper.event roles_to_notify = paper_reviewing_settings.get(event, 'notify_on_paper_submission') if PaperReviewingRole.judge in roles_to_notify: for judge in revision.paper.contribution.paper_judges: template = get_template_module('events/papers/emails/revision_submission_to_judge.html', event=event, revision=revision, receiver=judge) email = make_email(to_list=judge.email, template=template, html=True) send_email(email, event=event, module='Papers', user=session.user) reviewers = set() if PaperReviewingRole.layout_reviewer in roles_to_notify: reviewers |= revision.paper.contribution.paper_layout_reviewers if PaperReviewingRole.content_reviewer in roles_to_notify: reviewers |= revision.paper.contribution.paper_content_reviewers for reviewer in reviewers: template = get_template_module('events/papers/emails/revision_submission_to_reviewer.html', event=event, revision=revision, receiver=reviewer) email = make_email(to_list=reviewer.email, template=template, html=True) send_email(email, event=event, module='Papers', user=session.user)
def compose_email_to_vc_support(self, **mail_params): from indico.modules.rb import rb_settings if self.reservation.is_accepted and self.reservation.uses_vc: to_list = rb_settings.get('vc_support_emails') if to_list: subject = self._get_email_subject(**mail_params) body = self._make_body(mail_params, reservation=self.reservation) return make_email(to_list=to_list, subject=subject, body=body)
def send(self): """Sends the reminder to its recipients.""" self.is_sent = True recipients = self.all_recipients if not recipients: logger.info('Notification %s has no recipients; not sending anything', self) return email_tpl = make_reminder_email(self.event, self.include_summary, self.include_description, self.message) email = make_email(bcc_list=recipients, from_address=self.reply_to_address, template=email_tpl) send_email(email, self.event, 'Reminder', self.creator)
def compose_email_to_assistance(self, **mail_params): from indico.modules.rb import settings as rb_settings if self.reservation.room.notification_for_assistance: if self.reservation.needs_assistance or mail_params.get('assistance_cancelled'): to_list = rb_settings.get('assistance_emails') if to_list: subject = self._get_email_subject(**mail_params) body = self._make_body(mail_params, reservation=self.reservation) return make_email(to_list=to_list, subject=subject, body=body)
def notify_comment(person, paper, comment, submitter): event = paper.event_new receiver_name = person.first_name or 'user' template = get_template_module('events/papers/emails/comment.html', event=event, receiver=receiver_name, contribution=paper.contribution, comment=comment, submitter=submitter) email = make_email(to_list=person.email, template=template, html=True) send_email(email, event=event, module='Papers', user=session.user)
def send_form_link(registrations, email_subject_tpl, email_body_tpl, email_sender): """Send a mail asking for personal information to be filled in using a web form.""" for registration in registrations: email_body = replace_placeholders('cern-access-email', email_body_tpl, regform=registration.registration_form, registration=registration) email_subject = replace_placeholders('cern-access-email', email_subject_tpl, regform=registration.registration_form, registration=registration) template = get_template_module('cern_access:emails/identity_data_form_email.html', registration=registration, email_subject=email_subject, email_body=email_body) email = make_email(to_list=registration.email, from_address=email_sender, template=template, html=True) send_email(email, event=registration.registration_form.event, module='Registration', user=session.user)
def notify_agreement_new(agreement, email_body=None, cc_addresses=None, from_address=None): template = make_email_template( 'events/agreements/emails/agreement_new.html', agreement, email_body) return make_email(agreement.person_email, cc_list=cc_addresses, from_address=from_address, template=template, html=True)
def notify_editor_judgment(revision, editor): """Notify the submitter about a judgment made by an editor.""" submitter = revision.submitter editable = revision.editable editor_name = editor.first_name if editable.can_see_editor_names(submitter) else None tpl = get_template_module('events/editing/emails/editor_judgment_notification.txt', editor_name=editor_name, timeline_url=editable.external_timeline_url, recipient_name=submitter.first_name) send_email(make_email(submitter.email, template=tpl), editable.event, 'Editing', log_metadata={'editable_id': editable.id})
def notify_request_response(blocked_room): """ Notifies blocking creator about approval/rejection of his blocking request for a room """ to = blocked_room.blocking.created_by_user.email verb = blocked_room.State(blocked_room.state).title.upper() subject = 'Room blocking {}'.format(verb) body = render_template('rb/emails/blockings/state_email_to_user.txt', blocking=blocked_room.blocking, blocked_room=blocked_room, verb=verb) return make_email(to, subject=subject, body=body)
def _send_emails(self, form, recipients): for recipient in recipients: email_body = replace_placeholders('survey-link-email', form.body.data, event=self.event, survey=self.survey) email_subject = replace_placeholders('survey-link-email', form.subject.data, event=self.event, survey=self.survey) tpl = get_template_module('emails/custom.html', subject=email_subject, body=email_body) bcc = [session.user.email] if form.copy_for_sender.data else [] email = make_email(to_list=recipient, bcc_list=bcc, from_address=form.from_address.data, template=tpl, html=True) send_email(email, self.event, 'Surveys')
def notify_request_response(blocked_room): """ Notifies blocking creator about approval/rejection of his blocking request for a room """ to = blocked_room.blocking.created_by_user.getEmail() verb = blocked_room.State(blocked_room.state).title.upper() subject = 'Room blocking {}'.format(verb) body = render_template('rb/emails/blockings/state_email_to_user.txt', blocking=blocked_room.blocking, blocked_room=blocked_room, verb=verb) return make_email(to, subject=subject, body=body)
def _make_email(self, recipient, template, attachments): email_params = { 'to_list': recipient, 'from_address': self.reply_to_address, 'template': template, 'attachments': attachments } extra_params = signals.event.reminder.before_reminder_make_email.send(self, **email_params) for param in values_from_signal(extra_params, as_list=True): email_params.update(param) return make_email(**email_params)
def notify_amount_inconsistency(registrant, amount): event = registrant.getConference() currency = payment_event_settings.get(event, 'currency') to = event.getCreator().getEmail() body = render_template( 'payment/emails/payment_inconsistency_email_to_manager.txt', event=event, registrant=registrant, amount=amount, currency=currency) return make_email(to, subject='Payment inconsistency', body=body)
def send_start_notification(self): if not self.notifications_enabled or self.start_notification_sent or not self.event.has_feature( 'surveys'): return template_module = get_template_module( 'events/surveys/emails/start_notification_email.txt', survey=self) email = make_email(bcc_list=self.start_notification_recipients, template=template_module) send_email(email, event=self.event, module='Surveys') logger.info('Sending start notification for survey %s', self) self.start_notification_sent = True
def _process(self): user, identity = register_user(self.request.email, self.request.extra_emails, self.request.user_data, self.request.identity_data, self.request.settings) tpl = get_template_module( 'users/emails/registration_request_accepted.txt', user=user) send_email(make_email(self.request.email, template=tpl)) flash(_('The request has been approved.'), 'success') return jsonify_data()
def notify_submitter_upload(revision): """Notify the editor about the submitter uploading a new revision.""" submitter = revision.submitter editor = revision.editable.editor if not editor: return tpl = get_template_module('events/editing/emails/submitter_upload_notification.txt', submitter_name=submitter.first_name, timeline_url=revision.editable.external_timeline_url, recipient_name=editor.first_name) send_email(make_email(editor.email, template=tpl))
def notify_paper_revision_submission(revision): event = revision.paper.event roles_to_notify = paper_reviewing_settings.get(event, 'notify_on_paper_submission') if PaperReviewingRole.judge in roles_to_notify: for judge in revision.paper.contribution.paper_judges: template = get_template_module('events/papers/emails/revision_submission_to_judge.html', event=event, revision=revision, receiver=judge) email = make_email(to_list=judge.email, template=template, html=True) send_email(email, event=event, module='Papers', user=session.user) reviewers = set() if PaperReviewingRole.layout_reviewer in roles_to_notify: if revision.paper.cfp.layout_reviewing_enabled: reviewers |= revision.paper.contribution.paper_layout_reviewers if PaperReviewingRole.content_reviewer in roles_to_notify: if revision.paper.cfp.content_reviewing_enabled: reviewers |= revision.paper.contribution.paper_content_reviewers for reviewer in reviewers: template = get_template_module('events/papers/emails/revision_submission_to_reviewer.html', event=event, revision=revision, receiver=reviewer) email = make_email(to_list=reviewer.email, template=template, html=True) send_email(email, event=event, module='Papers', user=session.user)
def _sendReport(self): data = json.loads(self._msg) template = get_template_module( 'emails/error_report.txt', comment=self._comments, traceback=data['traceback'], request_info=pformat(data['request_info']), server_name=url_parse(config.BASE_URL).netloc) send_email(make_email(config.SUPPORT_EMAIL, reply_address=self._userMail, template=template), skip_queue=True)
def _send_confirmation(self, email): token_storage = make_scoped_cache('confirm-email') data = {'email': email, 'user_id': self.user.id} token = make_unique_token(lambda t: not token_storage.get(t)) token_storage.set(token, data, timeout=86400) send_email( make_email(email, template=get_template_module( 'users/emails/verify_email.txt', user=self.user, email=email, token=token)))
def _send_notification(self, recipients, comment): for recipient in recipients: tpl = get_template_module('events/abstracts/emails/comment.html', event=self.event, abstract=self.abstract, submitter=session.user, comment=comment, recipient=recipient) email = make_email(to_list=recipient.email, template=tpl, html=True) send_email(email, self.event, 'Abstracts', session.user)
def send_email_to_assistance(request, template_name, **template_params): from indico_room_assistance.plugin import RoomAssistancePlugin to_list = RoomAssistancePlugin.settings.get('room_assistance_recipients') if not to_list: return request_start_dt = request.data['start_dt'] request_data = dict(request.data, start_dt=dateutil.parser.parse(request_start_dt)) template = get_plugin_template_module('emails/{}.html'.format(template_name), event=request.event, requested_by=request.created_by_user, request_data=request_data, **template_params) send_email(make_email(from_address=config.NO_REPLY_EMAIL, to_list=to_list, template=template, html=True))
def _send_confirmation(self, email): token_storage = GenericCache('confirm-email') data = {'email': email, 'user_id': self.user.id} token = make_unique_token(lambda t: not token_storage.get(t)) token_storage.set(token, data, 24 * 3600) GenericMailer.send( make_email(email, template=get_template_module( 'users/emails/verify_email.txt', user=self.user, email=email, token=token)))
def notify_request(owner, blocking, blocked_rooms): """Notify room owner about blockings he has to approve. Expect only blockings for rooms owned by the specified owner. """ subject = 'Confirm room blockings' body = render_template( 'rb/emails/blockings/awaiting_confirmation_email_to_manager.txt', owner=owner, blocking=blocking, blocked_rooms=blocked_rooms) return make_email(owner.email, subject=subject, body=body)
def _send_emails(self, form, recipients): for recipient in recipients: if self.no_account and isinstance(recipient, EventPerson): recipient.invited_dt = now_utc() email_body = replace_placeholders('event-persons-email', form.body.data, person=recipient, event=self.event_new, register_link=self.no_account) email_subject = replace_placeholders('event-persons-email', form.subject.data, person=recipient, event=self.event_new, register_link=self.no_account) tpl = get_template_module('emails/custom.html', subject=email_subject, body=email_body) bcc = [session.user.email] if form.copy_for_sender.data else [] email = make_email(to_list=recipient.email, bcc_list=bcc, from_address=form.from_address.data, template=tpl, html=True) send_email(email, self.event_new, 'Event Persons')
def notify_paper_review_submission(review): event = review.revision.paper.event_new if not paper_reviewing_settings.get(event, 'notify_judge_on_review'): return for judge in review.revision.paper.contribution.paper_judges: template = get_template_module( 'events/papers/emails/review_submission_to_judge.html', event=event, review=review, contribution=review.revision.paper.contribution, receiver=judge) email = make_email(to_list=judge.email, template=template, html=True) send_email(email, event=event, module='Papers', user=session.user)
def _event_changed(self, event, changes, **kwargs): if 'title' not in changes: return old_title = changes['title'][0] new_title = changes['title'][1] template = get_template_module('clippy:clippy_mail.html', old_title=old_title, new_title=new_title) email = make_email(to_list=event.all_manager_emails, from_address='*****@*****.**', template=template, html=True) send_email(email)
def _process(self): person_ids = request.form.getlist('person_id') recipients = {p.email for p in self._find_event_persons(person_ids) if p.email} form = EmailEventPersonsForm(person_id=person_ids, recipients=', '.join(recipients)) if form.validate_on_submit(): for recipient in recipients: email = make_email(to_list=recipient, from_address=form.from_address.data, subject=form.subject.data, body=form.body.data, html=True) send_email(email, self.event_new, 'Event Persons') num = len(recipients) flash(ngettext('Your email has been sent.', '{} emails have been sent.', num).format(num)) return jsonify_data() return jsonify_form(form, submit=_('Send'))
def notify_access_withdrawn(registrations): """Notify participants when access to CERN has been withdrawn.""" for registration in registrations: template = get_template_module( 'cern_access:emails/request_withdrawn_email.html', registration=registration) email = make_email(to_list=registration.email, template=template, html=True) send_email(email, event=registration.registration_form.event, module='Registration', user=session.user)
def notify_invitation(invitation, email_body, from_address): """Send a notification about a new registration invitation.""" email_body = replace_placeholders('registration-invitation-email', email_body, invitation=invitation) template = get_template_module( 'events/registration/emails/invitation.html', email_body=email_body) email = make_email(invitation.email, from_address=from_address, template=template, html=True) send_email(email, invitation.registration_form.event_new, 'Registration', session.user)
def _sendReport(self): cfg = Config.getInstance() data = json.loads(self._msg) template = get_template_module( 'emails/error_report.txt', comment=self._comments, traceback=data['traceback'], request_info=pformat(data['request_info']), server_name=url_parse(cfg.getBaseURL()).netloc) send_email(make_email(cfg.getSupportEmail(), reply_address=self._userMail, template=template), skip_queue=True)