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 _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 notify_move_request_creation(events, target_category, comment=''): """Send email notifications when a move request is created. :param events: List of events requested to move. :param target_category: The category to move the events into. :param comment: Optional requestor's comment. """ emails = set() query = (target_category.chain_query.filter(Category.notify_managers | ( Category.event_creation_notification_emails != [])).options( joinedload('acl_entries'))) # Walk up the category chain for cat in reversed(query.all()): emails.update( _get_emails_from_category(cat, ignore_notify_managers=True)) if emails: template = get_template_module( 'events/emails/move_request_creation.txt', events=events, target_category=target_category, comment=comment) send_email(make_email(bcc_list=emails, template=template)) break
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_new, 'Registration', session.user)
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.principal_type in (PrincipalType.user, PrincipalType.email): emails.add(manager.email) elif manager.principal_type in (PrincipalType.local_group, PrincipalType.multipass_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 room_assistance_emails(): inner = (Request.query.filter( Request.type == 'room-assistance', Request.state == RequestState.accepted).add_columns( func.jsonb_array_elements_text( Request.data['occurrences']).label('requested_at')).subquery()) aliased_event = aliased(Event, name='event') requests = (db.session.query(inner, aliased_event).join( aliased_event, aliased_event.id == inner.c.event_id).filter( aliased_event.own_room_id.isnot(None)).filter( db.cast(inner.c.requested_at, db.Date) == db.cast( now_utc(), db.Date)).all()) requests = [req._asdict() for req in requests] template = get_plugin_template_module('emails/room_assistance_emails.html', requests=requests, parse_dt=dateutil.parser.parse) recipients = RoomAssistancePlugin.settings.get( 'room_assistance_recipients') if recipients: email = make_email(from_address=config.NO_REPLY_EMAIL, to_list=recipients, template=template, html=True) send_email(email)
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 _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 _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_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 if session else None))
def _notify_registration(registration, template_name, to_managers=False, attach_rejection_reason=False): from indico.modules.events.registration.util import get_ticket_attachments attachments = [] regform = registration.registration_form tickets_handled = values_from_signal(signals.event.is_ticketing_handled.send(regform), single_value=True) if (not to_managers and regform.tickets_enabled and regform.ticket_on_email and not any(tickets_handled) and registration.state == RegistrationState.complete): attachments += get_ticket_attachments(registration) if not to_managers and registration.registration_form.attach_ical: event_ical = event_to_ical(registration.event) attachments.append(('event.ics', event_ical, 'text/calendar')) tpl = get_template_module(f'events/registration/emails/{template_name}', registration=registration, attach_rejection_reason=attach_rejection_reason) to_list = registration.email if not to_managers else registration.registration_form.manager_notification_recipients from_address = registration.registration_form.notification_sender_address if not to_managers else None mail = make_email(to_list=to_list, template=tpl, html=True, from_address=from_address, attachments=attachments) user = session.user if session else None signals.core.before_notification_send.send('notify-registration', email=mail, registration=registration, template_name=template_name, attach_rejection_reason=attach_rejection_reason) send_email(mail, event=registration.registration_form.event, module='Registration', user=user, log_metadata={'registration_id': registration.id})
def _notify_registration(registration, template, to_managers=False): from indico.modules.events.registration.util import get_ticket_attachments attachments = None regform = registration.registration_form tickets_handled = values_from_signal( signals.event.is_ticketing_handled.send(regform), single_value=True) if (not to_managers and regform.tickets_enabled and regform.ticket_on_email and not any(tickets_handled) and registration.state == RegistrationState.complete): attachments = get_ticket_attachments(registration) template = get_template_module( 'events/registration/emails/{}'.format(template), registration=registration) to_list = registration.email if not to_managers else registration.registration_form.manager_notification_recipients from_address = registration.registration_form.sender_address if not to_managers else None mail = make_email(to_list=to_list, template=template, html=True, from_address=from_address, attachments=attachments) send_email(mail, event=registration.registration_form.event, module='Registration', user=session.user)
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_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_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 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 %s', self)
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_abstract_notifications(abstract): """Send abstract notification e-mails. :param abstract: the abstract that is going to be checked against the event's notification rules :return: whether an email has been sent """ sent = False for email_tpl in abstract.event.abstract_email_templates: matched = False for rule in email_tpl.rules: if check_rule('abstract-notifications', rule, abstract=abstract, event=abstract.event): 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, abstract.event, 'Abstracts', session.user) abstract.email_logs.append(AbstractEmailLogEntry.create_from_email(email, email_tpl=email_tpl, user=session.user)) sent = True if email_tpl.stop_on_match and matched: break return sent
def _process(self): db.session.delete(self.request) tpl = get_template_module( 'users/emails/registration_request_rejected.txt', req=self.request) send_email(make_email(self.request.email, template=tpl)) flash(_('The request has been rejected.'), 'success') return jsonify_data()
def _send_emails(self, form): for registration in self.registrations: email_body = replace_placeholders('registration-email', form.body.data, regform=self.regform, registration=registration) email_subject = replace_placeholders('registration-email', form.subject.data, regform=self.regform, registration=registration) template = get_template_module( 'events/registration/emails/custom_email.html', email_subject=email_subject, email_body=email_body) bcc = [session.user.email] if form.copy_for_sender.data else [] attach_ticket = 'attach_ticket' in form and form.attach_ticket.data and not registration.is_ticket_blocked attachments = get_ticket_attachments( registration) if attach_ticket else None email = make_email(to_list=registration.email, cc_list=form.cc_addresses.data, bcc_list=bcc, from_address=form.from_address.data, template=template, html=True, attachments=attachments) send_email(email, self.event, 'Registration')
def notify_pending(acl_entry): """Sends a notification to a user with an email-based ACL entry :param acl_entry: An email-based EventPrincipal """ assert acl_entry.type == PrincipalType.email if acl_entry.full_access: template_name = 'events/emails/pending_manager.txt' endpoint = 'event_mgmt.conferenceModification-managementAccess' elif acl_entry.has_management_role('submit', explicit=True): template_name = 'events/emails/pending_submitter.txt' endpoint = 'event.conferenceDisplay' else: return event = acl_entry.event_new email = acl_entry.principal.email template = get_template_module(template_name, event=event, email=email, url=url_for_register(url_for( endpoint, event), email=email)) send_email(make_email(to_list={email}, template=template), event.as_legacy, module='Protection')
def _notify_changes_in_reviewing_team(user, template, event, role): template = get_template_module(template, event=event, receiver=user, role=role) email = make_email(to_list=user.email, template=template, html=True) send_email(email, event=event, module='Papers', user=session.user)
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_paper_revision_submission(revision): event = revision.paper.event_new 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 notify_comment(comment): """Notify about a new comments on a revision.""" revision = comment.revision editor = revision.editable.editor author = comment.user if comment.internal: # internal comments notify the editor and anyone who commented + can see internal comments recipients = _get_commenting_users( revision, check_internal_access=True) | {editor} elif author == editor: # editor comments notify the submitter and anyone else who commented recipients = _get_commenting_users(revision) | {revision.submitter} elif revision.editable.can_perform_submitter_actions(author): # submitter comments notify the editor and anyone else who commented recipients = _get_commenting_users(revision) | {editor} else: # comments from someone else (managers) notify everyone recipients = _get_commenting_users(revision) | { editor, revision.submitter } recipients.discard(None) # in case there's no editor assigned recipients.discard(author) # never bother people about their own comments for recipient in recipients: tpl = get_template_module( 'events/editing/emails/comment_notification.txt', author_name=author.first_name, timeline_url=revision.editable.external_timeline_url, recipient_name=recipient.first_name) send_email(make_email(recipient.email, template=tpl))
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 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 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_editor_judgment(revision, editor): """Notify the submitter about a judgment made by an editor.""" submitter = revision.submitter tpl = get_template_module('events/editing/emails/editor_judgment_notification.txt', editor_name=editor.first_name, timeline_url=revision.editable.external_timeline_url, recipient_name=submitter.first_name) send_email(make_email(submitter.email, template=tpl))
def send_ticket(registration): """Send the ticket to access the CERN site by email.""" start_dt, end_dt = get_access_dates(get_last_request(registration.event)) template = get_template_module('cern_access:emails/ticket_email.html', registration=registration, start_dt=start_dt, end_dt=end_dt) attachments = get_ticket_attachments(registration) email = make_email(to_list=registration.email, template=template, html=True, attachments=attachments) send_email(email, event=registration.registration_form.event, module='Registration', user=session.user)
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 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 _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_new, 'Registration')
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 _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(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 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 _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 _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('events/persons/emails/email.html', subject=email_subject, body=email_body) email = make_email(to_list=recipient.email, from_address=form.from_address.data, template=tpl, html=True) send_email(email, self.event_new, 'Event Persons')
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, register_link=self.no_account) email_subject = replace_placeholders('event-persons-email', form.subject.data, person=recipient, event=self.event, 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, 'Event Persons')
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 _send_emails(self, form): for registration in self.registrations: email_body = replace_placeholders('registration-email', form.body.data, regform=self.regform, registration=registration) email_subject = replace_placeholders('registration-email', form.subject.data, regform=self.regform, registration=registration) template = get_template_module('events/registration/emails/custom_email.html', email_subject=email_subject, email_body=email_body) bcc = [session.user.email] if form.copy_for_sender.data else [] attachments = (get_ticket_attachments(registration) if 'attach_ticket' in form and form.attach_ticket.data else None) email = make_email(to_list=registration.email, cc_list=form.cc_addresses.data, bcc_list=bcc, from_address=form.from_address.data, template=template, html=True, attachments=attachments) send_email(email, self.event, 'Registration')
def _notify_registration(registration, template, to_managers=False): attachments = None regform = registration.registration_form tickets_handled = values_from_signal(signals.event.is_ticketing_handled.send(regform), single_value=True) if (not to_managers and regform.tickets_enabled and regform.ticket_on_email and not any(tickets_handled) and registration.state == RegistrationState.complete): attachments = get_ticket_attachment(registration) template = get_template_module('events/registration/emails/{}'.format(template), registration=registration) to_list = registration.email if not to_managers else registration.registration_form.manager_notification_recipients from_address = registration.registration_form.sender_address if not to_managers else None mail = make_email(to_list=to_list, template=template, html=True, from_address=from_address, attachments=attachments) send_email(mail, event=registration.registration_form.event, module='Registration', user=session.user)
def notify_paper_judgment(paper, reset=False): event = paper.event authors = [x for x in paper.contribution.person_links if x.is_author] recipients = ([x for x in authors if x.email] if paper.last_revision.submitter.is_system else [paper.last_revision.submitter]) template_file = None if reset: template_file = 'events/papers/emails/judgment_reset_to_author.html' elif paper_reviewing_settings.get(event, 'notify_author_on_judgment'): template_file = 'events/papers/emails/judgment_to_author.html' if not template_file: return for receiver in recipients: template = get_template_module(template_file, event=event, paper=paper, contribution=paper.contribution, receiver=receiver) email = make_email(to_list=receiver.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 notify_pending(acl_entry): """Sends a notification to a user with an email-based ACL entry :param acl_entry: An email-based EventPrincipal """ assert acl_entry.type == PrincipalType.email if acl_entry.full_access: template_name = 'events/emails/pending_manager.txt' endpoint = 'event_mgmt.conferenceModification-managementAccess' elif acl_entry.has_management_role('submit', explicit=True): template_name = 'events/emails/pending_submitter.txt' endpoint = 'event.conferenceDisplay' else: return event = acl_entry.event_new email = acl_entry.principal.email template = get_template_module(template_name, event=event, email=email, url=url_for_register(url_for(endpoint, event), email=email)) send_email(make_email(to_list={email}, template=template), event.as_legacy, module='Protection')
def _process_evaluation(event): """Processes the notification for a single evaluation :return: ``True`` if the event shouldn't be checked for evaluation notifications again because the notification has been sent or shouldn't be sent at all. """ evaluation = event.getEvaluation() now = now_utc() if not evaluation.isVisible(): # Evaluation disabled? We shouldn't be here. Simply don't # do anything and disable the send_notification flag. return True elif now >= evaluation.getEndDate(): # Evaluation finished. Doesn't make lots of sense either # but in that case we also don't want to spam people. return True elif not evaluation.getNbOfQuestions(): # Evaluation is empty. return True elif now < evaluation.getStartDate(): # Evaluation not started yet. Don't do anything in this # case but keep checking the event. return False notification = evaluation.getNotification(Evaluation._EVALUATION_START) if not notification or (not notification.getToList() and not notification.getCCList()): # Notifications disabled return True tpl = get_template_module('events/evaluation/emails/evaluation_started.txt', event=event, evaluation=evaluation) # XXX: This is terrible, putting possibly all the participants in `To`. We should really use BCC for this! email = make_email(notification.getToList(), notification.getCCList(), template=tpl) send_email(email, event, 'Evaluation') return True
def _process(self): db.session.delete(self.request) tpl = get_template_module('users/emails/registration_request_rejected.txt', req=self.request) send_email(make_email(self.request.email, template=tpl)) flash(_('The request has been rejected.'), 'success') return jsonify_data()